Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 100;
  6.  
  7. int main(void){
  8. int n, m, a[N][N];
  9. int pr = 1; // переменная для произведения
  10. cout << "Input num of lines:" << endl;
  11. cin >> n;
  12. cout << "Input num of columns:" << endl;
  13. cin >> m;
  14. for(int i = 0; i < n; ++i){ // цикл по строкам
  15. for(int j = 0; j < m; ++j){ // цикл по столбцам внутри строки
  16. cin >> a[i][j]; // считываем j-ый элемент i-ой строки
  17. pr *= a[i][j]; // насчитываем произведение элементов
  18. }
  19. }
  20. int lines = n; // количество нужных строк, сначала это все строки, потом будем уменьшать , если строка не подходит
  21.  
  22. for(int i = 0; i < n; ++i){
  23. for(int j = 0; j < m - 1; ++j){
  24. if(a[i][j] < a[i][j + 1]){ // если строка не подходит под условие
  25. lines--; // вычитаем из общего числа строк эту строку
  26. break; // завершаем цикл по j, чтобы не вычесть это строку еще раз
  27. }
  28. }
  29. }
  30. cout << "Lines num: " << lines << endl;
  31. cout << "Multiplication: " << pr << endl;
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement