So this is the program description as per hw requirements.
The following is a procedure for constructing an n x n magic square for any odd integer n.
Place 1 in the middle column of the top row.
Then after integer k has been placed, move up one row and one column to the right to place the next integer k + 1, unless one of the following occurs:
If a move takes you above the top row in the ith column, move to the bottom of the ith column and place k + 1 there
If a move takes you outside to the right of the square in the ith row, place k + 1 in the ith row at the left side.
If a move takes you to an already filled square or if you move out of the square at the upper right-hand corner, place k + 1 immediately below k.
Write a program to construct n x n magic square for any odd value of n.
thnx
#include <iostream>
using namespace std;
void fillmatrix(int matrix[][n], int size);
int main()
{
int n;
cout<<"Enter the integer value for your magic square"<<endl;
cin>>n;
int matrix[n][n];
fillmatrix(matrix, n);
return 0;
}
void fillmatrix(int matrix[][n], int size)
{
for(int row = 0; row < size; row++)
{
for()
{
//not sure how to set this part up
}
}
}