arrays - JAVA not entering for loop -


heads up, small small part of school project, , such have tried keep asking guys write code me.

as ground: trying populate char[][] array in spiral manner, think have algorithm work, however, case is... not working.

but right having trouble getting code enter , execute in loop. here small snippet...

in specific example running k char[] array length 10 , pt char[] array of length 92

    box2 = new char[height][k.length];     int c = 0;     int limit = pt.length; //ensures while loop doesint attempt populate past array bounds     int w = k.length; //width of array     int h = height; //height of array     //these 2 variable trying use count how many blocks      //filled on outside of spiral.     //example.. spiral populates inward, can no longer travel entire     //length of array, 1 less block every pass     int difh = 0; //difference in height     int difw = 0; //difference in width     while (limit > 0) {          (int n = 0; n < (w - (w - difw)); n++) {             box[h - (h - difh)][n] = pt[c];             limit--;         }     } 

for whatever reason when step through code in netbeans not enter or execute loop, or of other three.

can me figure out why code wont enter or execute loop?

in case wish see entire while loop:

    while (limit > 0) {          (int n = 0; n < (w - (w - difw)); n++) {             box[h - (h - difh)][n] = pt[c];             limit--;         }         difh--;         (int n = h - (h - difh); n > 0; n--) {             box[n][w - (w - difw)] = pt[c];             limit--;         }         difw--;          (int n = w - (w - difw); n > 0; n--) {             box[h - (h - difh)][n] = pt[c];             limit--;         }         difh--;         (int n = 0; n < h - (h - difh); n++) {             box[n][w - (w - difw)] = pt[c];             limit--;         }         difw--;      }      //prints box2     //prints box array     int counter2 = 0;     (int column = 0; column < box2.length; column++) {         if (column > 0) {             system.out.print("|");         }         system.out.println();         (int r = 0; r < box2[column].length; r++) {              system.out.print("|" + box2[column][r]);         }     }     system.out.println("|\n"); 

if screwed beyond understandability (as entirely possible), please let me know , edit or maybe reevaluate algorithm.

n < (w - (w - difw)) false:

(w - (w - difw)) = (w-w+difw) = (0+difw) = difw 

but set difw 0, n 0, , 0 < 0 false


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -