Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
argh ~~
Posted by Chin Loong on October 26, 2001 at 5:02 AM
dang... they don't capture the spaces >,< #assuming leftbottom most square is (0,0) and coord <=> (i,j) 1. i don't know why but i always start with the top row of the matrix, in the middle. place "1" there. ((int)(i_max/2)+1),j_max) 2. head northeast. (i+1,j+1) for(int NUMBER=2;NUMBER<=nxn;NUMBER++) { ....IF it's a valid square (inside the matrix and empty) ....{ ........place the NUMBER there. ....} ....ELSE (it's not a valid square) ....{ ........IF it's outside the matrix ........{ ............IF the destination column (i+1) is valid (inside matrix) ............{ ................place the NUMBER at the bottom of the column (i+1,j_min) ............} ............ELSE IF the destination row (j+1) is valid (inside matrix) ............{ ................place the next number at the left end of the row (i_min,j+1) ............} ............ELSE IF both the column and row not valid  outside matrix) ............{ ................go down one square (i,j1) and place the NUMBER there ............} ........} ........ELSE (if not invalid square, must be nonempty square) ........{ ............go down one square (i,j1) and place the NUMBER there ........} ....} }
Replies:
 Argh ~~ Matt Gerrans October 26, 2001 at 3:51 PM
(0)
 boxes galore ~ Chin Loong October 26, 2001 at 5:08 AM
(6)
