m0_51586823 2021-04-19 17:21 采纳率: 75%
浏览 59
已采纳

求解java编程题,关于数组的题目,谢谢大神

 

  • 写回答

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 25 

    Maximum 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
     

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改