题解 | #二维数组操作#

二维数组操作

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

import java.util.*;
public class Main {
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int r,c,r1,c1,r2,c2,ri,ci,rt,ct;
            while(sc.hasNext()){
                r=sc.nextInt();
                c=sc.nextInt();
                r1=sc.nextInt();
                c1=sc.nextInt();
                r2=sc.nextInt();
                c2=sc.nextInt();
                ri=sc.nextInt();
                ci=sc.nextInt();
                rt=sc.nextInt();
                ct=sc.nextInt();
                
                if(r<=9 && c<=9){
                    System.out.println(0);
                }else{
                    System.out.println(-1);
                }
                
                if((r1<r&&r2<r) && (c1<c&&c2<c)){
                    System.out.println(0);
                }else{
                    System.out.println(-1);
                }
                
              //插入行和列的时候,要注意,只有在原来的行和列是小于9的情况下才能插入
                if(ri<r&&r<9){
                    System.out.println(0);
                }else{
                    System.out.println(-1);
                }
                
                if(ci<c&&c<9){
                    System.out.println(0);
                }else{
                    System.out.println(-1);
                }
                
              //无论怎么插入行和列, 表格永远是初始的规格大小
                if(rt<r && ct<c){
                    System.out.println(0);
                }else{
                    System.out.println(-1);
                }
            }
        }
}
全部评论
这题目确实把人搞晕了,如果不是看了这个答案,还以为确实要去搞一个二维数组呢。
点赞 回复 分享
发布于 2022-03-05 15:37

相关推荐

评论
点赞
2
分享

创作者周榜

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