#K57822. Magic Square Generator
Magic Square Generator
Magic Square Generator
Given an odd integer \(n\) (i.e., \(n = 1, 3, 5, \dots\)), generate an \(n \times n\) magic square where every row, every column, and both main diagonals have the same sum. The magic constant is given by \(M = \frac{n(n^2+1)}{2}\). Use the Siamese method to fill the square. If the provided integer is even, output the error message: n must be an odd number
.
inputFormat
The input consists of a single line containing one integer \(n\), where \(n\) must be an odd number.
outputFormat
If \(n\) is odd, output the magic square in \(n\) lines where each line contains \(n\) space-separated integers. If \(n\) is even, output the error message: n must be an odd number
.
1
1