Been working on this magic square problem for a while now and I'm stuck, I have no idea what to do next, I'm pretty new to c++ so any help would be great. thanks
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main(void) {
int n;
cout << "Enter a value for n" <<
<< "n cannot be an odd integer" << endl;
cin >> n;
void magic(n) {
for row = 0 to n-1
for col = 0 to n-1
square[row][col] = 0
}
int main(void) {
const n
row = 0;
col = n/2;
}
for (i = 1 to n^2) {
square[row][col] = i
row--
col++
}
//compensate for the edges
if square[row][col] != 0
col--
row+=2
//compensate for the edges
}
}
//output the square
return 0;
#include <iostream>
#include <cstdlib>
usingnamespace std;
int n;
cout << "Enter a value for n" <<
<< "n cannot be an odd integer" << endl;
cin >> n;
void magic(n) {
for row = 0 to n-1
for col = 0 to n-1
square[row][col] = 0
}
int main(void) {
const n
row = 0;
col = n/2;
}
for (i = 1 to n^2) {
square[row][col] = i
row--
col++
}
//compensate for the edges
if square[row][col] != 0
col--
row+=2
//compensate for the edges
}
}
//output the square
cout << square << endl;
return 0;
}
Yeah tell me about it, I'm an engineering major, and this is the only programming class I have to take, and it's the first programming class I've ever taken. And this is our second project, I'm kinda in over my head..