Advertisement
Kentoo

A#1

Dec 4th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include "windows.h"
  4. #include "time.h"
  5.  
  6. using namespace std;
  7.  
  8. void main()
  9. {
  10.     SetConsoleCP(1251);
  11.     SetConsoleOutputCP(1251);
  12.     const int n = 5, m = 5;
  13.     int a[n][m];
  14.     srand(time(NULL));
  15.     int max = 0, q = 0;
  16.     for (int i = 0; i < n; i++) {
  17.         srand(rand() % 100);
  18.         for (int j = 0; j < m; j++) {
  19.             a[i][j] = rand() % 20 - 10;
  20.             if (a[i][j] > max) {
  21.                 max = a[i][j];
  22.                 q = i;
  23.             }
  24.         }
  25.     }
  26.     for (int i = 0; i < n; i++) {
  27.         for (int j = 0; j < m; j++) {
  28.             cout << a[i][j] << " ";
  29.         }
  30.         cout << endl;
  31.     }
  32.     for (int i = q + 1; i < n; i ++) {
  33.         for (int j = 0; j < m; j++) {
  34.             if (a[i][j] < 0) {
  35.                 a[i][j] = a[i][j] * a[i][j];
  36.             }
  37.         }
  38.     }
  39.     cout << endl;
  40.     for (int i = 0; i < n; i++) {
  41.         for (int j = 0; j < m; j++) {
  42.             cout << a[i][j] << " ";
  43.         }
  44.         cout << endl;
  45.     }
  46.     system("pause");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement