x2311

Untitled

Dec 22nd, 2021
1,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 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]{
  9.             {17, 6,  17, 8,  7,  17},
  10.             {7,  5,  4,  65, 9,  48},
  11.             {1,  1,  4,  0,  6,  -96},
  12.             {7,  3,  4,  5,  53, 0},
  13.             {0,  -1, 4,  5,  73, 14},
  14.             {1,  -2, 4,  -5, 74, -9},
  15.  
  16.     };
  17.  
  18.     int sum = 0;
  19.     cout << "->" << endl;
  20.     for (int i = 0, j = sizeof(arr) / SIZE / sizeof(int) - 1; i < SIZE; ++i) {
  21.         if (arr[j][i] > 0) {
  22.             sum += arr[j][i];
  23.  
  24.             cout << i << " - " << j << endl;
  25.         }
  26.     }
  27.     cout << "↑" << endl;
  28.     for (int i = 0, j = SIZE - 1; i < sizeof(arr) / SIZE / sizeof(int) - 1; ++i) {
  29.         if (arr[i][j] > 0) {
  30.  
  31.             sum += arr[i][j];
  32.             cout << j << " - " << i << endl;
  33.         }
  34.     }
  35.     cout << "sum: " << sum << endl;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment