Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int a[501][501];
- int main()
- {
- int n, i, j, sa=0, s=0, ok=0, dp, ds, x;
- cin>>n;
- for(j=1; j<=n; j++)
- {
- cin>>a[1][j];
- sa=sa+a[1][j];
- }
- dp=a[1][1];
- ds=a[1][n];
- for(i=2; i<=n; i++)
- {
- for(j=1; j<=n; j++)
- {
- cin>>a[i][j];
- x=a[i][j];
- s=s+x;
- if(i==j)
- {
- dp=dp+x;
- }
- if(i+j == 1+n)
- {
- ds=ds+x;
- }
- if(sa==s)
- {
- ok=0;
- }
- else
- {
- ok++;
- }
- }
- if(ok==0)
- {
- sa=s;
- s=0;
- }
- }
- if(ok==0 && ds==sa && dp==sa)
- {
- cout<<"true";
- }
- else
- {
- cout<<"false";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement