-->
当前位置:首页 > 题库

PROGRAMMING:N-magic square matrix

Luz5年前 (2021-05-10)题库472
The so-called "n-magic square matrix" refers to the use of 1 ~ N2, a total of N2 natural numbers arranged into an n × The square matrix of n. The sum of every row, column and diagonal elements of the matrix is equal, and is a constant only related to N, which is n ×( n2+1)/2。
This problem requires the realization of n-magic square matrix (order up to 20) n value read from the keyboard, the problem to ensure that the value of n is odd.
###Input format:
Enter a value that gives an odd number n on a line.
###Output format:
Output the corresponding n-magic square matrix according to the format of the sample, 5 characters in each column, right aligned.
###Input example:
```in
five
```
###Output example:
```out
The generated 5-cube matrix is as follows:
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
```







answer:If there is no answer, please comment