题解 | 上三角矩阵判定

上三角矩阵判定

https://www.nowcoder.com/practice/f5a29bacfc514e5a935723857e1245e4

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt(),t = 1;
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    int m = in.nextInt(); 
                    if( j < i && m != 0 && t==1){
                        System.out.println("NO");
                        t=0;
                    }               
            }   
            }
            if( t==1){
                        System.out.println("YES");
                    } 
        }
    }
}

全部评论

相关推荐

鲸鸿:实习协议不用管签多久,要走的时候提前三天说就可以了
点赞 评论 收藏
分享
找工作勤劳小蜜蜂:矛盾是没有实习,就是没实战经验,公司不想要,公司不要,你就没有实习,你就进入死循环,另外你的项目不是社会现在有大量岗位存在行业用的,云存储人员早就饱和。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务