palenda21

экз1

Jan 8th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n;
  7.     cout << "Vvedite n: ";
  8.     cin >> n;
  9.     int mass[n][n];
  10.     cout << "Vvedite elementi massiva: ";
  11.     for (int i = 0; i < n; i++)
  12.     {
  13.         for (int j = 0; j < n; j++)
  14.         {
  15.             cout << "[" << i << "]" << "[" << j << "] = ";
  16.             cin >> mass[i][j];
  17.         }
  18.     }
  19.     cout << "Massiv: " << endl;
  20.     for (int i = 0; i < n; i++)
  21.     {
  22.         for (int j = 0; j < n; j++)
  23.         {
  24.             cout << setw(3) << mass[i][j] << setw(3);
  25.         }
  26.         cout << endl;
  27.     }
  28.     int sum = 0;
  29.     for (int i = 0; i < n; i++)
  30.     {
  31.         for (int j = 0; j < n; j++)
  32.         {
  33.             if (mass[i][j] % 2 == 0)
  34.             {
  35.                 sum += mass[i][j];
  36.             }
  37.         }
  38.     }
  39.     cout << "sum = " << sum << endl;
  40.     double sr = 0;
  41.     for (int i = 0; i < n; i++)
  42.     {
  43.         sr += mass[i][2];
  44.     }
  45.     sr /= n;
  46.     cout << "sr = " << sr << endl;
  47. }
Add Comment
Please, Sign In to add comment