Laitofai

Untitled

Jun 8th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, arr[100][100], arr2[100], cnt = 0;
  8. /*
  9. arr = матрица
  10. arr2 = там будут храниться номера строк
  11. cnt = количество неубывающих строк
  12. */
  13. bool flag;
  14. cin >> n;
  15. for(int i = 0; i < n; i++){
  16. for(int j = 0; j < n; j++){
  17. cin >> arr[i][j];
  18. }
  19. }
  20. for(int i = 0; i < n; i++){
  21. flag = false;
  22. for(int j = 0; j < n - 1; j++){
  23. if(arr[i][j] > arr[i][j+1]){
  24. flag = true; // если строка i убывающая - поднимаем флаг
  25. break;
  26. }
  27. }
  28. if(flag == false){
  29. arr2[cnt] = i;
  30. cnt++;
  31. }
  32. }
  33. if(cnt != 0){
  34. for(int i = 0; i < cnt; i++){
  35. cout << arr2[i] << " ";
  36. }
  37. }else{
  38. cout << "NO";
  39. }
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment