I modified my program to make all rows and column to add to 15 in 3x3, that will prevent the noncontinuous problem u state earlier. However i got a new problem. I don't know why my code doesn't work after i set it all rows and column to and diagonal to add to 15.
Here's the problem in my if function.
((a + b + c == 15)&& (d + e + f == 15) && (g + h + i == 15)&& (a + d + g == 15) till this point it worked, after this point my code doesn't work && (b + e + h == 15) &&(c + f + i == 15) && (a + e + i == 15) && (g + e + c == 15)&& (a!=b!=c!=d!=e!=f!=g!=h!=i))
Some how the first column which is a + d + g == 15 worked, but after i add b + e + h == 15 and so on, not matter what magic square matrix i input my code say it's not magic square. Why?
}
int a = matrix[0][0];//11
int b = matrix[0][1];//12
int c = matrix[0][2];//13
int d = matrix[1][0];//21
int e = matrix[1][1];//22
int f = matrix[1][2];//23
int g = matrix[2][0];//31
int h = matrix[2][1];//32
int i = matrix[2][2];//33
if ((a + b + c == 15)&& (d + e + f == 15) && (g + h + i == 15)&& (a + d + g == 15) && (b + e + h == 15) &&(c + f + i == 15) && (a + e + i == 15) && (g + e + c == 15)&& (a!=b!=c!=d!=e!=f!=g!=h!=i))
cout <<" this is a magic square"<<endl;
else
cout <<" this is not a magic square"<<endl;