1、从键盘输入一个整数(120)则以该数字为矩阵的大小,把 1,2,3n*n 的数字按照顺时针螺旋的形式填入其中。例如:输入数字 2,则程序输出:1 24 3输入数字 3,则程序输出:1 2 38 9 47 6 5输入数字 4, 则程序输出:1 2 3 412 13 14 511 16 15 610 9 8 7package suanfa;public class JuZhen public static void main(String args)int arrayNum = 6;int array = new intarrayNumarrayNum;printHY(array,0);print
2、HZ(array,0);printSX(array,0);printSS(array,0);if(arrayNum % 2 != 0)arrayarrayNum/2arrayNum/2 = arrayNum * arrayNum;println(array);public static void println(int array)for(int i = 0;i array.length/2 -1)return;int startNum = 1;for(int num = 0 ;num array.length/2 -1)return;int startNum = (array.length-
3、1) *2 +1;for(int num = 0 ;num array.length/2 -1)return;int startNum = array.length;for(int num = 0 ;num array.length/2 -1)return;int startNum = (array.length) *3 -2;for(int num = 0 ;numcen;num+)startNum = (array.length - 1 - num*2)* 1+(array.length - 1 - (num+1)*2) * 3+startNum;int h = array.length-1 -cen;int s = cen;for(int time = 0; time array.length - 1-cen*2;time+,startNum+)arrayhs = startNum;h-;printSS(array,cen+1);