Question: Implement the following algorithm to construct magic n n squares; it works only if n is odd. Set row = n - 1, column
Implement the following algorithm to construct magic n × n squares; it works only if n is odd.
Set row = n - 1, column = n / 2.
For k = 1 ... n * n
Place k at [row][column].
Increment row and column.
If the row or column is n, replace it with 0.
If the element at [row][column] has already been filled
Set row and column to their previous values.
Decrement row.
Here is the 5 × 5 square that you get if you follow this method:

Write a program whose input is the number n and whose output is the magic square of order n if n is odd.
11 18 25 2 9 10 12 19 21 3 4 6 13 20 22 23 5 7 14 16 17 24 1 8 15
Step by Step Solution
3.38 Rating (167 Votes )
There are 3 Steps involved in it
To generate an array with ten random numbers between 1 and 100 for int i0 i 10 ... View full answer
Get step-by-step solutions from verified subject matter experts
