TableTester.java
资源名称:Java.rar [点击查看]
上传用户:szfcled
上传日期:2022-06-12
资源大小:236k
文件大小:1k
源码类别:
文件格式
开发平台:
Java
- public class TableTester {
- public static void main(String args[]) {
- int myTable[][] = {
- {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}};
- int sum, max, maxRow=0;
- max = 0; //Assume all numbers are positive
- for (int row=0; row<4; row++) {
- sum = 0;
- for (int col=0; col<7; col++)
- sum += myTable[row][col];
- if (sum > max) {
- max = sum;
- maxRow = row;
- }
- }
- System.out.println("Row " + maxRow + " has the highest sum of " + max);
- }
- }