Description
The so-called "N-level cube" is a number filling game ~ N ^ 2 numbers are repeatedly filled in a square matrix consisting of n rows and n columns, N ^ 2 squares, the sum of numbers in each row, column, and diagonal line in the square matrix is equal to the same number, and N is an odd number.
(Follow the 89 pages of the teaching material strictly.AlgorithmOperation. If the write is not performed as required, the non-AC status will occur and the consequences will be borne by you)
-
Input
-
The first behavior t indicates that T groups of data exist.
Each of the following lines contains an integer n (n <= 10)
-
Output
-
Corresponding to the Cube filled in for each N output, each number has a space, each n numbers a row
Find the rule and print it cyclically.
# Include <stdio. h> main () {int A [99] [99]; int N, I, j, R; int number, Te; scanf ("% d", & number ); for (TE = 1; te <= number; Te ++) {scanf ("% d", & N); for (I = 0; I <99; I ++) {for (j = 0; j <99; j ++) {A [I] [J] = 0 ;}} I = 0; j = n/2; A [I] [J] = 1; for (r = 2; r <= N * n; r ++) if (A [(I + N-1) % N] [(j + 1) % N] = 0) {I = (I + N-1) % N; j = (J + 1) % N; A [I] [J] = r;} else {I = (I + 1) % N; A [I] [J] = r ;}for (I = 0; I <n; I ++) {for (j = n-1; j> = 0; j --) {printf ("% d", a [I] [J]);} printf ("\ n ");}}}