4DM3M

Оаип 3

Jul 6th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7.     setlocale(LC_ALL, "rus");
  8.     int a[10][10], n;
  9.  
  10.     cout << "Введите n: ";
  11.     cin >> n;
  12.  
  13.     cout << "Введите матрицу порядка " << n << ":\n";
  14.     for (int i = 0; i < n; i++)
  15.     {
  16.         for (int j = 0; j < n; j++)
  17.         {
  18.             cin >> a[i][j];
  19.         }
  20.     }
  21.  
  22.     int sum = 0;
  23.    
  24.     for (int i = 0; i < n; i++)
  25.     {
  26.         for (int j = 0; j < n; j++)
  27.         {
  28.             if ((i > j) && (a[i][j] > 0))
  29.             {
  30.                 sum += a[i][j];
  31.             }
  32.         }
  33.     }
  34.    
  35.     cout << endl << sum << endl;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment