2条回答 默认 最新
- allway2 2021-04-19 19:03关注
package sample; public class CsdnArray { public static void main(String[] args) { int[][] array = new int[5][6]; for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[0].length; j++) { array[i][j] = i * i - (j - i) * (j - i) + 10; System.out.print(array[i][j] + " "); } System.out.println(); } System.out.println(); // getMaximumOfEveryRow () for (int i = 0; i < array.length; i++) { int max = Integer.MIN_VALUE; for (int j = 0; j < array[i].length; j++) if (array[i][j] > max) max = array[i][j]; System.out.println("Maximum of row " + i + " = " + max); } // getMinimumOfEveryColumn for (int i = 0; i < array[0].length; i++) { int min = Integer.MAX_VALUE; for (int j = 0; j < array.length; j++) if (array[j][i] < min) min = array[j][i]; System.out.println("Minimum of column " + i + " = " + min); } } }
10 9 6 1 -6 -15
10 11 10 7 2 -5
10 13 14 13 10 5
10 15 18 19 18 15
10 17 22 25 26 25Maximum of row 0 = 10
Maximum of row 1 = 11
Maximum of row 2 = 14
Maximum of row 3 = 19
Maximum of row 4 = 26
Minimum of column 0 = 10
Minimum of column 1 = 9
Minimum of column 2 = 6
Minimum of column 3 = 1
Minimum of column 4 = -6
Minimum of column 5 = -15
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何制作永久二维码,最好是微信也可以扫开的。(相关搜索:管理系统)
- ¥15 delphi indy cookie 有效期
- ¥15 labelme打不开怎么办
- ¥35 按照图片上的两个任务要求,用keil5写出运行代码,并在proteus上仿真成功,🙏
- ¥15 免费的电脑视频剪辑类软件如何盈利
- ¥30 MPI读入tif文件并将文件路径分配给各进程时遇到问题
- ¥15 pycharm中导入模块出错
- ¥20 Ros2 moveit2 Windows环境配置,有偿,价格可商议。
- ¥15 有关“完美的代价”问题的代码漏洞
- ¥15 请帮我看一下这个简易化学配平器的逻辑有什么问题吗?