Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool magkvadrat(int** a, int n)
- {
- int k,i, j;
- bool b = true;
- int sumstr, sumstlb, sumdiag = 0, sumpobdiag = 0, sum=0;
- for (j = 0; j < n; j++)
- sum = sum + a[0][j];
- for (i = 0; i < n && b; i++)
- {
- sumstr = 0;
- sumstlb = 0;
- for (j = 0; j < n; j++)
- {
- sumstr = sumstr + a[i][j];
- sumstlb = sumstlb + a[j][i];
- if (i == 0)
- {
- sumdiag = sumdiag + a[j][j];
- sumpobdiag = sumpobdiag + a[j][n - 1 - j];
- }
- }
- if (sumstr != sum || sumstlb != sum || sumdiag != sum || sumpobdiag != sum)
- b = false;
- }
- return b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement