这题其实不算二维数组的题目,并不需要实际建立二维数组,只需要挨个判断条件是否满足即可



import java.util.Scanner;

//针对各种操作作判断,并不一定需要对矩阵实际操作
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int m = in.nextInt();
            int n = in.nextInt();

            //判断建立操作
            if(m <=9 && n <=9) System.out.println(0);
            else System.out.println(-1);

            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();

            //判断交换
            if(x1 < m && x2 < m && y1 < n && y2 < n)
                System.out.println(0);
            else
                System.out.println(-1);

            //判断插入
            int in_x = in.nextInt();
            int in_y = in.nextInt();

             if(m+1 <= 9 && in_x < m) System.out.println(0);
            else System.out.println(-1);

            if(n+1 <= 9 && in_y < n) System.out.println(0);
            else System.out.println(-1);

            //判断查询
            int x = in.nextInt();
            int y = in.nextInt();
            if(x < m && y < n) System.out.println(0);
            else System.out.println(-1);

        }
    }
}