Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <iostream>
- using namespace std;
- void main()
- {
- const int n = 3;
- int i, j, max;
- int a[n][n];
- int b[n][n];
- int c[n][n];
- srand(time(0));
- for (i = 0; i < n; i++)
- for (j = 0; j < n; j++)
- a[i][j] = rand() % 10; // заполнение
- cout << " array A" << endl;
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < n; j++)
- cout << setw(3) << a[i][j]; // вывод на экран A массива
- cout << endl;
- }
- cout << endl;
- for (i = 0; i < n; i++)
- for (j = 0; j < n; j++)
- b[i][j] = rand() % 10; // заполнение
- cout << " array B" << endl;
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < n; j++)
- cout << setw(3) << b[i][j]; // вывод на экран B массива
- cout << endl;
- }
- cout << "------------- Max into array B----------------" << endl;
- //////////////////////////////////////////////////////////////
- for (i = 0; i < n; i++)
- {
- int max = b[i][0]; //поиск максимального
- for (j = 0; j < n; j++)
- if (max < b[i][j])
- max = b[i][j];
- for (j = 0; j < n; j++)
- {
- c[i][j] = a[i][j] * max;
- cout << setw(3) << c[i][j];
- }
- cout << "---------------" << max << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement