Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <ctime>
- #include <algorithm>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- setlocale(LC_ALL, "rus");
- int n;
- int max1 = 0;
- int max2 = 0;
- int max3 = 0;
- int a[100][100];
- cout << "Введите порядок матрицы n: ";
- cin >> n;
- cout << "Исходная матрица A" << endl;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- a[i][j] = rand() % 30 + 1;
- cout << setw(4) << a[i][j];
- }
- cout << "\n";
- }
- cout << "Итоговая матрица Б:" << endl;
- for (int k=1;k<n)
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j += n - 1)
- {
- if (a[i][j] > max1)
- {
- max1 = a[i][j];
- }
- }
- for (int j = 0; j < n; j++)
- {
- for (int i = 0; i < n; i += n - 1)
- {
- if (a[i][j] > max2)
- {
- max2 = a[i][j];
- }
- }
- }
- }
- max3 = max(max1, max2);
- for (int i = 0; i < (n + 1) / 2; i++)
- {
- for (int j = i; j < n; j++)
- {
- a[i][j] = max3;
- cout <<setw(4)<< a[i][i];
- }
- cout << "\n";
- }
- system("pause");
- return 0;
- }
- //for (int k = 0; k < n; k++)
- //{
- // for (int i = 0; i < n; i++)
- // {
- // for (int j = 0; j < n; j += n - 1)
- // {
- // if (a[i][j] > max1)
- // {
- // max1 = a[i][j];
- // }
- // }
- // }
- // for (int j = 0; j < n; j++)
- // {
- // for (int i = 0; i < n; i += n - 1)
- // {
- // if (a[i][j] > max2)
- // {
- // max2 = a[i][j];
- // }
- // }
- // }
- // max3 = max(max1, max2);
- // cout << max3;
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement