第八章第十题(最大的行和列)(Largest rows and columns)
-
*8.10(最大的行和列)编写一个程序,在一个4x4的矩阵中随机填入0和1,打印该矩阵,分别找到第一个具有最多1的行和列。下面是一个程序的运行示例:
0 0 0 1
0 0 1 0
0 1 0 1
1 0 1 0
The largest row index:2
The largest column index:2
*8.10(Largest rows and columns)Write a program, fill in 0 and 1 randomly in a 4x4 matrix, print the matrix, find the first row and column with up to 1. Here is an example of a program running:
0 0 0 1
0 0 1 0
0 1 0 1
1 0 1 0
The largest row index:2
The largest column index:2 -
参考代码:
package chapter08; public class Code_10 { public static void main(String[] args){ int[][] nums = new int[4][4]; for(int i = 0; i < 4; ++i){ for