DSTJZ


私信TA

用户名:dotcpp0721777

访问量:4748

签 名:

天下难事,必作于易;天下大事,必作于细。

等  级
排  名 49
经  验 11162
参赛次数 13
文章发表 321
年  龄 18
在职情况 学生
学  校 狗熊岭23届毕业生
专  业

  自我简介:

TA的其他文章


参考代码:

import java.util.Scanner;

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

        int oddrow = 0;//记录和为奇数的行数
        int row = 0;//记录和为奇数的行数的下标
        for(int i = 0; i < n; i++)
        {   int sum = 0;
            for(int j = 0; j < n; j++)
            {   sum += arr[i][j];
            }
            if(sum % 2 == 1)
            {   oddrow++;
                row = i;
            }
        }
        int oddcolumn = 0;//记录和为奇数的列数
        int column = 0;//记录和为奇数的列数的下标
        for(int i = 0; i < n; i++)
        {   int sum = 0;
            for(int j = 0; j < n; j++)
            {   sum += arr[j][i];
            }
            if(sum % 2 == 1)
            {    oddcolumn++;
                column = i;
            }
        }
        row++;//题目答案中的下标不是从0开始,而是从1开始的
        column++;
        if(oddcolumn == 0 && oddrow == 0)
            System.out.println("OK");
        else if(oddcolumn == 1 && oddrow == 1)
            System.out.println(row + " " + column);
        else
            System.out.println("Corrupt");
    }
}


 

0.0分

5 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区