Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, arr[100][100], arr2[100], cnt = 0;
- /*
- arr = матрица
- arr2 = там будут храниться номера строк
- cnt = количество неубывающих строк
- */
- bool flag;
- cin >> n;
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- cin >> arr[i][j];
- }
- }
- for(int i = 0; i < n; i++){
- flag = false;
- for(int j = 0; j < n - 1; j++){
- if(arr[i][j] > arr[i][j+1]){
- flag = true; // если строка i убывающая - поднимаем флаг
- break;
- }
- }
- if(flag == false){
- arr2[cnt] = i;
- cnt++;
- }
- }
- if(cnt != 0){
- for(int i = 0; i < cnt; i++){
- cout << arr2[i] << " ";
- }
- }else{
- cout << "NO";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment