#C12450. Magic Square Generation
Magic Square Generation
Magic Square Generation
Given an odd positive integer N (N ≥ 3), generate an N×N magic square using the Siamese method. In a magic square, the sum of every row, every column, and both main diagonals is constant. This constant, known as the magic constant, is given by the formula: $$M = \frac{N(N^2+1)}{2}$$.
For example, when N = 3, one possible magic square is:8 1 6
3 5 7
4 9 2
Your task is to implement a program that reads the integer N from standard input and prints the corresponding magic square to standard output, with each row on a new line and numbers separated by a single space.
inputFormat
A single odd integer N (N ≥ 3) provided via standard input.
outputFormat
Print the generated magic square. Each row should be output on a new line with the numbers separated by a single space.## sample
3
8 1 6
3 5 7
4 9 2
</p>