题目链接
题目描述
求解思路
- 暴力求解:由于数据量较小,对每个仓库进行遍历求解即可。
- 需要注意只有一个仓库的特殊情况。( n = 1 n=1 n=1的情况)
实现代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n, m;
Scanner in = new Scanner(System.in);
n = in.nextInt();
m = in.nextInt();
int[][] a = new int[n][m];
for (int i = 0; i < n; i ++) {
for (int j = 0; j < m; j ++) {
a[i][j] = in.nextInt();
}
}
for (int i = 0; i < n; i ++) {
boolean isFind = false;
for (int j = 0; j < n; j ++) {
if (i == j) {
continue;
} else {
isFind = true;
for (int k = 0; k < m; k ++) {
if (a[i][k] >= a[j][k]) {
isFind = false;
break;
}
}
if (isFind) {
System.out.println(j + 1);
break;
}
}
}
if (!isFind) {
System.out.println(0);
}
}
}
}
标签:Java,Scanner,isFind,int,202312,System,++,nextInt,CSP
From: https://blog.csdn.net/dawn191228/article/details/141388138