Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[25][25];
- int main()
- {
- int sum=0,n,summ=0;
- cin>>n;
- for(int i=0;i<n;++i)
- for(int j=0;j<n;++j)
- cin>>a[i][j];
- for(int i=0;i<n;++i)
- sum+=a[i][i];
- for(int i=0;i<n;++i)
- summ+=a[i][n-i-1];
- if(summ!=sum){cout<<summ<<"No";return 0;};
- for(int i=0;i<n;++i)
- {
- int summ=0;
- for(int j=0;j<n;++j)
- summ+=a[i][j];
- if(summ!=sum){cout<<"No";return 0;};
- }
- for(int i=0;i<n;++i)
- {
- int summ=0;
- for(int j=0;j<n;++j)
- summ+=a[j][i];
- if(summ!=sum){cout<<"No";return 0;};
- }
- cout<<"Yes";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement