Package com; </P> <p> public class count {<br/> Public static void print (INT count) {<br/> Int Is [] [] = new int [count] [count]; <br/> int I = 0; <br/> int c = count * count; <br/> // horizontal coordinate accumulators <br/> Int J = 0; <br/> // vertical coordinate accumulators <br/> int K = 0; <br/> // horizontal and vertical direction control, 1 is horizontal, -1 is vertical <br/> int M = 1; <br/> // coordinate accumulators, 1 is incremental,-1 is decreasing <br/> int n = 1; <br/> while (I <c) {<br/> is [J] [k] = ++ I; <br/> If (M> 0) {<br/> K + = N; <Br/> // trigger steering <br/> If (k <0 | K> = count | is [J] [k]! = 0) {<br/> M * =-1; <br/> K-= N; <br/> J + = N; <br/>}< br/>}else {<br/> J + = N; <br/> // trigger steering <br/> If (j <0 | j> = count | is [J] [k]! = 0) {<br/> M * =-1; <br/> J-= N; <br/> N * =-1; <br/> K + = N; <br/>}</P> <p> for (INT p = 0; P <count; ++ p) {<br/> for (INT q = 0; q <count; ++ q) <br/> system. out. print (is [p] [Q] + "/t"); <br/> system. out. println (); <br/>}< br/> Public static void main (string [] ARGs) {<br/> count hcount = new count (); <br/> hcount. print (7); <br/>}< br/>