思路:
1.二维数组当前行与其他行比较,所以前两个for循环都是<=n
2.每比较一次前,cnt清0
3.若满足条件,则输出所在行,并break,继续下一行与其他行的比较
4.已经找了所有行也没有满足的,条件就是j>n;输出0
#include <iostream>
using namespace std;
int main() {
int n, m;
int a[200][200];//要开更大
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> a[i][j];
}
}
int cnt;
for (int i = 1; i <= n; ++i) {
int j;
for (j = 1; j <= n; ++j) {
cnt = 0;
for (int k = 1; k <= m; ++k) {
if (a[i][k] < a[j][k]) { cnt++; }
}
if (cnt == m) { cout << j << endl; break; }
}
if (j > n)cout << 0 << endl;
}
return 0;
}