:?: I work on the program to function a Magic square, below as my working program, but I don't know how to print out the magic square using print function
any one can help?
#include<iostream>
#include<iomanip>
using namespace std;
const int n = 30;
int MagicSquareConstruct(int MagicSquare[n][n]);
int main()
{
int entrySize;
int MagicSquare[n][n];
cout<< "Please enter an integer n: ";
cin>>entrySize;
cout<< MagicSquareConstruct(MagicSquare) << endl;
}
int MagicSquareConstruct(int MagicSquare[n][n])
{
int newRow,
newCol;
// Set the indices for the middle of the bottom i
int i =0 ;
int j= n / 2;
// Fill each element of the array using the magic array
for ( int value = 1; value <= n*n; value++ )
{
MagicSquare[i][j] = value;
// Find the next cell, wrapping around if necessary.
newRow = (i + 1) % n;
newCol = (j + 1) % n;
// If the cell is empty, remember those indices for the
// next assignment.
if ( MagicSquare[newRow][newCol] == 0 )
{
i = newRow;
j = newCol;
}
else
{
// The cell was full. Use the cell above the previous one.
i = (i - 1 + n) % n;
}
}
}