A magic square is an n x n array which contains the integers from 1 to n squared, without repetition, in such a way that the sums of the components in any given column, and the sums of the components on each diagonal are all equal. The number n is called the order of the square. For example, the following are two magic squares of order 4:
16 2 3 13 7 12 1 14
5 11 10 8 2 13 8 11
9 7 6 12 16 3 10 5
4 14 15 1 9 6 15 4
Write a C++ program that tests a square array of order no more than 20
for being a magic square.
Test your program on the following two squares.
46 8 16 20 29 7 49 27 29 2 4 13 36
22 40 35 26 18 41 11 9 11 20 22 31 18
44 12 23 32 19 38 63 32 25 7 3 21 23
29 26 11 25 29 24 12 14 16 34 30 12 5
5 37 31 27 17 13 45 28 6 15 17 26 19
48 9 15 14 32 10 47 1 24 33 35 8 10
1 43 34 30 12 41 4