题解 | #密码强度等级#

二维数组操作

http://www.nowcoder.com/practice/2f8c17bec47e416897ce4b9aa560b7f4

import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int r = sc.nextInt();
            int c = sc.nextInt();
            
            int r1 = sc.nextInt();
            int c1 = sc.nextInt();
            int r2 = sc.nextInt();
            int c2 = sc.nextInt();
            
            int r3 = sc.nextInt();
            int c3 = sc.nextInt();
            
            int r4 = sc.nextInt();
            int c4 = sc.nextInt();
            
            if(r<=9 && c<=9){
                System.out.println(0);
            }else{
                System.out.println(-1);
            }
            
            if(r1<r && c1<c && r2<r && c2<c){
                System.out.println(0);
            }else{
                System.out.println(-1);
            }
            
            if(r+1<=9 && r3<r){
                System.out.println(0);
            }else{
                System.out.println(-1);
            }
            
            if(c+1<=9 && c3<c){
                System.out.println(0);
            }else{
                System.out.println(-1);
            }
            
            if(r4<=r-1 && c4<=c-1){
                System.out.println(0);
            }else{
                System.out.println(-1);
            }
        }
    }
}
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务