Advertisement
KedrikFeeD

Задача для Сёмы

Nov 25th, 2021
1,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include "ctime"
  3. using namespace std;
  4. int main() {
  5.     const int n = 5;
  6.     int a[n][n];
  7.  
  8.     for (int i = 0; i < n; i++) {
  9.         for (int j = 0; j < n; j++) {
  10.             a[i][j] = rand() % 100 - 50;
  11.         }
  12.     }
  13.     for (int i = 0; i < n; i++) {
  14.         for (int j = 0; j < n; j++) {
  15.             cout << a[i][j] << '\t';
  16.         }
  17.         cout << endl;
  18.     }
  19.     cout << endl;
  20.     for (int i = 0; i < n; i++) {
  21.         for (int j = 0; j < n; j++) {
  22.             if (i < j) {
  23.                 a[i][j] = 0;
  24.             }
  25.             if (i > j) {
  26.                 a[i][j] = -1;
  27.             }
  28.         }
  29.     }
  30.     for (int i = 0; i < n; i++) {
  31.         for (int j = 0; j < n; j++) {
  32.             cout << a[i][j] << '\t';
  33.         }
  34.         cout << endl;
  35.     }
  36.     cout << endl;
  37.     for (int i = 0; i < n; i++) {
  38.         for (int j = 0; j < n; j++) {
  39.             if (i + j < n - 1) {
  40.                 a[i][j] = -2;
  41.             }
  42.             if (i + j > n - 1) {
  43.                 a[i][j] = -3;
  44.             }
  45.         }
  46.     }
  47.     for (int i = 0; i < n; i++) {
  48.         for (int j = 0; j < n; j++) {
  49.             cout << a[i][j] << '\t';
  50.         }
  51.         cout << endl;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement