Generating magic squaresTopTic Tac ToeMagic squares

Magic squares

Let's look at a program that generates "magic squares" and stores them in two-dimensional arrays. A square array of numbers is said to be a "magic square" if all the rows, columns, and diagonals add up to the same number. For example, here is a 3 ×3 magic square:

   4 9 2
   3 5 7
   8 1 6

Each row, column, and diagonal of this square add up to 15.


Generating magic squaresTopTic Tac ToeMagic squares