Quick Help Needed! Lo Shu Magic Square

So I need to create a "magic square"
that is to say that every row pillar and diagonal add up to the same number here is what I have to find the grid using a 2d array.
not sure where to go from here..Thanks so much!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
#include <iostream>
using namespace std;
int main ()
{


int matrix[3][3] = {{1,2,3,}, {4,5,6}, {7,8,9}};


	for (int i = 0; i < 3; i++) {
		for (int j = 0; j <3; j++)

			cout<<"  "<<matrix[j][i];
		cout<<endl;

	}
	return 0;
}

Last edited on
Topic archived. No new replies allowed.