题解 | #HJ083 二维数组操作#

二维数组操作

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

import java.util.Scanner;

/**
 * HJ83 二维数组操作 - 简单
 */
public class HJ083 {

    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);
            }
        }
        sc.close();
    }
}
全部评论
看到热点答案和我的一样,我也放心了。此题太傻瓜了。
点赞 回复 分享
发布于 2023-01-13 22:41 陕西

相关推荐

10-13 13:49
南京大学 财务
饿魔:笑死我了,你简直是个天才
点赞 评论 收藏
分享
评论
10
收藏
分享

创作者周榜

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