壮Sir不壮


私信TA

用户名:dotcpp0692568

访问量:760

签 名:

等  级
排  名 1278
经  验 2921
参赛次数 0
文章发表 17
年  龄 0
在职情况 学生
学  校 河南科技学院
专  业

  自我简介:

解题思路:

注意事项:

参考代码:


public class Test {
   public static void main(String[] args) {
       Scanner scanner = new Scanner(System.in);
       int[] [] arr = new int[5][5];
       for (int i = 0;i<5;i++) {
           for (int j = 0;j<5;j++) {
               arr[i][j] = scanner.nextInt();
           }
       }


       int [] maxRow = new int[5];//存放每行的最大值
       int index1 = 0;
       int [] minCol = new int[5];//存放每列的最小值
       int index2 = 0;

       int row = 0;
       int col = 0;

       for (int i = 0;i<5;i++) {
           row = 0;
           col = Integer.MAX_VALUE;

           for (int j = 0;j<5;j++) {
               row = Math.max(row, arr[i][j]);//找出每行最大的值
               col = Math.min(col, arr[j][i]);//找出每列最小的值
           }
           maxRow[index1++] = row;//将每行的最大值添加到数组中
           minCol[index2++] = col;//将每列的最小值添加到数组中
       }
       
       
       boolean isExit = false; //是否有鞍点

       for (int i = 0;i<5;i++) {
           for (int j = 0;j<5;j++) {
               if (maxRow[i] == minCol[j]) {
                   isExit = true;
                   System.out.printf("%d %d %d\n", i+1,j+1, maxRow[i]);
               }
           }
       }

       if (!isExit) System.out.println("not found");

   }
}



 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区