1.用Java编写程序,求下列二维数组中各行元素之和并查找其值最大的那个行。 数组在问题补充里

如题所述

public static void main(String[] args) {
int[][] arr = {{23, 45, 65, 34, 21, 67, 78},{46, 14, 18, 46, 98, 63, 88},{98, 81, 64, 90, 21, 14, 23},{54, 43, 55, 76, 22, 43, 33}};

for (int i = 0; i < arr.length; i++) {
int total=0;
for (int j = 0; j < arr[i].length; j++) {
total += arr[i][j];
}
System.out.println("第"+i+"行的和为:"+total);
}
}

记录每行的下标以及和,然后用排序算法查找其最大行
温馨提示:答案为网友推荐,仅供参考