托尔


私信TA

用户名:jlau2012100320

访问量:453

签 名:

等  级
排  名 39652
经  验 341
参赛次数 1
文章发表 2
年  龄 0
在职情况 学生
学  校 吉林农业大学
专  业

  自我简介:

TA的其他文章

这是一个很快的Java代码,还可以有优化的空间,但懒得优化了


参考代码:

import java.util.Scanner;

public class Main {

    public static void main(String[] as) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int l = scanner.nextInt();
            Integer[][] needs = new Integer[l][l];
            boolean check = true;
            for (int x = 0; x < l; x++) {
                for (int y = 0; y < l; y++) {
                    int input = scanner.nextInt();
                    if (!check) {
                        continue;
                    }
                    Integer need = needs[x][y];
                    if (need == null) {
                        needs[y][x] = input;
                    } else if (need != input) {
                        check = false;
                    }
                }
            }
            if(check){
                System.out.println("Yes!");
            }else{
                System.out.println("No!");
            }
        }
    }
}


 

0.0分

1 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区