我需要计算用户输入只有0的行数,比如
Test 1
0 0 0
1 2 3
2 2 1
Test 2
1 2 3
0 0 0
0 0 0
Rows with only 0 values: 3
这是读取矩阵的代码
final int rows = 3, cols = 3;
Scanner input = new Scanner(System.in);
System.out.println("Number of tests");
int n = input.nextInt();
int test[][][] = new int[n][rows][cols];
for (int i = 0; i < n; i++) {
System.out.println("Test "+(i+1));
for (int j = 0; j < rows; j++) {
for (int k = 0; k < cols; k++) {
test[i][j][k] = input.nextInt();
}
}
}
暂无答案!
目前还没有任何答案,快来回答吧!