x2311

Untitled

Dec 19th, 2021
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int SIZE = 6;
  6.  
  7. int main() {
  8.     int arr[SIZE][SIZE]{
  9.             {0, 3,  9, 5,  7,  17},
  10.             {1, 3,  4, 65, 9,  48},
  11.             {1, 32, 4, 0,  6,  96},
  12.             {7, 0,  4, 5,  53, 0},
  13.             {0, 3,  4, 5,  73, 14},
  14.             {1, 3,  4, 5,  74, 9},
  15.     };
  16.     //array output
  17.     for (auto &i: arr) {
  18.         for (int j: i)
  19.             cout << " " << j;
  20.         cout << endl;
  21.     }
  22.     int d1 = 0, d2 = SIZE - 1, sum = 0, sumAll = 0;
  23.     for (int i = 0; i < sizeof(arr) / (SIZE * sizeof(int)); i++) {
  24.         for (int j = 0; j < SIZE; j++) {
  25.             if (j != d1 && j != d2) {
  26.                 sum += arr[i][j];
  27.             }
  28.         }
  29.         cout << endl << "sum " << i + 1 << ": " << sum;
  30.         sumAll += sum;
  31.         sum = 0;
  32.         d1++;
  33.         d2--;
  34.     }
  35.  
  36.     cout << endl << "\n\nSum All: " << sumAll;
  37.  
  38. }
  39.  
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment