Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Клюкин Вадим Лабораторная№ 5 Вариант 37
- Дана целочисленная матрица {Aij}i=1,...,n;j=1,...,m (n,m<=20)
- Найти произведение максимальных элементов столбцов.*/
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int n, m;
- cout << "Введите кол-во строк " << endl;
- cin >> n;
- cout << "Введите кол-во столбцов " << endl;
- cin >> m;
- cout << "Введите матрицу " << endl;
- int A[20][20];
- for(int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- cin >> A[i][j];
- int mult = 1;
- for (int j = 0; j < m; j++)
- {
- int maximum = INT_MIN;
- for (int i = 0; i < n; i++)
- if (A[i][j] > maximum)
- maximum = A[i][j];
- mult = mult * maximum;
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- cout << A[i][j] << " ";
- cout << "\n";
- }
- cout << "Максимальное произведение элементов столбцов " << mult;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement