Advertisement
elephantsarecool

magickvdrt

Jan 18th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int a[25][25];
  4. int main()
  5. {
  6.     int sum=0,n,summ=0;
  7.     cin>>n;
  8.     for(int i=0;i<n;++i)
  9.         for(int j=0;j<n;++j)
  10.             cin>>a[i][j];
  11.     for(int i=0;i<n;++i)
  12.         sum+=a[i][i];
  13.     for(int i=0;i<n;++i)
  14.         summ+=a[i][n-i-1];
  15.     if(summ!=sum){cout<<summ<<"No";return 0;};
  16.     for(int i=0;i<n;++i)
  17.     {
  18.         int summ=0;
  19.         for(int j=0;j<n;++j)
  20.             summ+=a[i][j];
  21.         if(summ!=sum){cout<<"No";return 0;};
  22.     }
  23.       for(int i=0;i<n;++i)
  24.     {
  25.         int summ=0;
  26.         for(int j=0;j<n;++j)
  27.             summ+=a[j][i];
  28.         if(summ!=sum){cout<<"No";return 0;};
  29.     }
  30.     cout<<"Yes";
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement