SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iomanip> | |
| 2 | #include <iostream> | |
| 3 | using namespace std; | |
| 4 | ||
| 5 | void main() | |
| 6 | {
| |
| 7 | const int n = 3; | |
| 8 | int i, j, max; | |
| 9 | int a[n][n]; | |
| 10 | int b[n][n]; | |
| 11 | int c[n][n]; | |
| 12 | ||
| 13 | srand(time(0)); | |
| 14 | for (i = 0; i < n; i++) | |
| 15 | for (j = 0; j < n; j++) | |
| 16 | a[i][j] = rand() % 10; // заполнение | |
| 17 | cout << " array A" << endl; | |
| 18 | ||
| 19 | for (i = 0; i < n; i++) | |
| 20 | {
| |
| 21 | for (j = 0; j < n; j++) | |
| 22 | cout << setw(3) << a[i][j]; // вывод на экран A массива | |
| 23 | cout << endl; | |
| 24 | } | |
| 25 | cout << endl; | |
| 26 | ||
| 27 | ||
| 28 | for (i = 0; i < n; i++) | |
| 29 | for (j = 0; j < n; j++) | |
| 30 | b[i][j] = rand() % 10; // заполнение | |
| 31 | ||
| 32 | cout << " array B" << endl; | |
| 33 | for (i = 0; i < n; i++) | |
| 34 | {
| |
| 35 | for (j = 0; j < n; j++) | |
| 36 | cout << setw(3) << b[i][j]; // вывод на экран B массива | |
| 37 | cout << endl; | |
| 38 | } | |
| 39 | ||
| 40 | cout << "------------- Max into array B----------------" << endl; | |
| 41 | ////////////////////////////////////////////////////////////// | |
| 42 | for (i = 0; i < n; i++) | |
| 43 | {
| |
| 44 | int max = b[i][0]; //поиск максимального | |
| 45 | ||
| 46 | for (j = 0; j < n; j++) | |
| 47 | if (max < b[i][j]) | |
| 48 | max = b[i][j]; | |
| 49 | ||
| 50 | for (j = 0; j < n; j++) | |
| 51 | {
| |
| 52 | c[i][j] = a[i][j] * max; | |
| 53 | cout << setw(3) << c[i][j]; | |
| 54 | } | |
| 55 | ||
| 56 | cout << "---------------" << max << endl; | |
| 57 | ||
| 58 | } | |
| 59 | } |