SHARE
TWEET

Untitled

a guest Dec 11th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int x[100][100],n,s1=0,s2=0,i,j;
  7.     cin>>n;
  8.     for(i=0; i<n; i++)
  9.         for(j=0; j<n; j++)
  10.             cin>>x[i][j];
  11.     for(i=0; i<n; i++)
  12.         s1+=x[i][i];
  13.     for(i=0; i<n; i++)
  14.         for(j=0; j<n; j++)
  15.             if(i+j==n-1)
  16.                 s2+=x[i][j];
  17.     if(s1-s2<0)
  18.         cout<<(-1)*(s1-s2);
  19.     else
  20.         cout<<s1-s2;
  21.     return 0;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top