MohamedAbdel3al

Matrix

Aug 8th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <bits/stdc++.h>
  4. using namespace std ;
  5. typedef long long ll ;
  6.  
  7.  
  8. int main() {
  9.  
  10. ios_base::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nullptr) ;
  11. int n , summd = 0 , sumsd = 0;
  12. cin >> n ;
  13. int arr[n][n] ;
  14. for (int i = 0; i < n; i++) {
  15. for (int j = 0; j < n && cin >> arr[i][j] ; j++) {
  16. }
  17. }
  18. for (int i = 0; i < n; i++) {
  19. for (int j = 0; j < n; j++) {
  20. if (i == j)
  21. summd += arr[i][j] ;
  22. }
  23. }
  24. for (int i = 0; i < n; i++) {
  25. for (int j = n - 1; j > 0; j--) {
  26. sumsd += arr[0][n - 1] ;
  27. n-- ;
  28. i++ ;
  29. }
  30. }
  31. cout << abs(summd - sumsd) ;
  32. return 0 ;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment