# Include <stdio. h>
Main ()
{
Int A [16] [16], I, J, K, P, M, N;
P = 1;
While (P = 1)
{
Printf ("Please input N (1 <n <15, n is single)/n ");
Scanf ("% d", & N );
If (n! = 0) & (n <= 15) & (N % 2! = 0 ))
{
Printf ("Rang is: % d/N", N );
P = 0;
}
}
For (I = 1; I <= N; I ++)/* init the rang */
For (j = 1; j <= N; j ++)
A[J] = 0;
J = n/2 + 1;
A [1] [J] = 1;
For (k = 2; k <= N * n; k ++)
{
I = I-1;
J = J + 1;
If (I <1) & (j> N ))
{
I = I + 2;
J = J-1;
}
Else
{
If (I <1) I = N;
If (j> N) j = 1;
}
If ([J] = 0)
A[J] = K;
Else
{
I = I + 2;
J = J-1;
A[J] = K;
}
}
For (I = 1; I <= N; I ++)
{
For (j = 1; j <= N; j ++)
Printf ("% 5d",[J]);
Printf ("/N ");
}
Getch ();
}In short, the magic square matrix is a continuous integer of 1, 2, 3 ...., numbers of N are arranged in the square matrix in a special order. add the number of each row, the number of each column, or the number of diagonal lines. The sum is the same. the magic square matrix, also known as the magic square matrix, is a digital arrangement that has been circulating for thousands of years. Both Chinese and western sides have studied this wonderful array. the magic square matrix is actually translated by the West "Magic qua re". Of course, there are also different names in the east. in China, we call it "magic". In ancient China, we called it "Landscape Chart. japan is called "Phalanx ". according to the [theory] and [stars], the Magic Square map has a mysterious pattern engraved on the back of a turtle around three thousand years ago when Xia Yu managed the water, people name it [Luo shu]. this square matrix has a peculiar nature, that is, every row, every column, and the number and number on the diagonal lines are both 15. the ancestors thought that "Luo shu" is a symbol of good fortune, so many people put it on paper and think it has a safe effect. in other regions of the East, there is also a legend of magic, but most of them are also covered with mysterious colors. one of the earlier stages was carved on a temple stone in India. It was about the 11th century and a fourth-level magic. ancient Indians worship this magic square, so far from the ruins of the ancient temple, the ruins of the fourth magic square can often be found on the tombstone. so far, many Indians have put the [Book] pattern on their chests as a "Amulet ". according to ancient chinese mathematics books. A three-row and three-column landscape chart is recorded in the [data record. it was called [9guan]. since Luo shu has a total of nine numbers, Xu Yue of the Han Dynasty called it "jiugong computing" (or jiugong). After the Han Dynasty, there was a great expansion, returns a portrait of N rows. in the Song dynasty of the 10th century, some people joined the [Luo Publishing] in the [jiugong] and [Yishu], collectively referred to as [Luo shu]. in 1275 AD, Yang Yi, a Chinese mathematician, further imitated Luo shu in the "ancient odd algorithm" and calculated the five-five Magic Square, six-six Magic Square .... jiujiu Magic Square and baizi Magic Square (ten level magic square. in the past 200 years, many people have used their brains for this problem, but there are not many achievements. frenicle de Bessy (1693) in a book, it is proposed that there are only eight three-level cube arrays, and there are 7040 four-level cube arrays, and many people will verify that they are correct. however, the total number of fifth-level Rubik's Cube arrays was not obtained by Richard Schroeppel in 1973 using electronic computers until it took about 100 hours. In addition, the total number of normal magic parties at level 6 and above has not been obtained. in the magic square matrix formula, the number of each row is equal to = Number and = number of each row and (magic number) × number of rows n (n + 1) = m × N --- & gt; M = n (n + 1) So we can use this formula to calculate the magic of the Magic Square Matrix: level 3 Magic Square magic number 15 Level 4 Magic Square magic number 34 level 5 Magic Square magic number 65 magic phalanx make Song Level 3 Magic Square (number of the Nine Palaces): [9 sub oblique row, up and down to different, the left and right sides are more, the four dimensions are straight out, wearing nine clothes and one clothes, the left three, the right seven, the second four are shoulder, and the sixth eight is foot.] level 4 Magic Square (overcast, change with four inner angles, six for eleven, seven for ten, straight up and down angle, all 34 numbers, on the last point can be applied to small.]