Advertisement
Rayzven

Untitled

Nov 21st, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. /*Клюкин Вадим Лабораторная№ 5 Вариант 37
  2. Дана целочисленная матрица {Aij}i=1,...,n;j=1,...,m (n,m<=20)
  3. Найти произведение максимальных элементов столбцов.*/
  4. #include "pch.h"
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. setlocale(LC_ALL, "Russian");
  12.  
  13. int n, m;
  14. cout << "Введите кол-во строк " << endl;
  15. cin >> n;
  16. cout << "Введите кол-во столбцов " << endl;
  17. cin >> m;
  18.  
  19. cout << "Введите матрицу " << endl;
  20. int A[20][20];
  21. for(int i = 0; i < n; i++)
  22. for (int j = 0; j < m; j++)
  23. cin >> A[i][j];
  24. int mult = 1;
  25. for (int j = 0; j < m; j++)
  26. {
  27. int maximum = INT_MIN;
  28. for (int i = 0; i < n; i++)
  29. if (A[i][j] > maximum)
  30. maximum = A[i][j];
  31. mult = mult * maximum;
  32. }
  33. for (int i = 0; i < n; i++)
  34. {
  35. for (int j = 0; j < m; j++)
  36. cout << A[i][j] << " ";
  37. cout << "\n";
  38. }
  39. cout << "Максимальное произведение элементов столбцов " << mult;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement