注意最后一行查找x y的数据时,要和前面的插入x,y区分开 定义成x0 y0否则会报错 #include<stdio.h> int main(void) { int m, n; int x1, y1, x2, y2; int x, y; int x0, y0; while (scanf("%d%d%d%d%d%d%d%d%d%d", &m, &n, &x1, &y1, &x2, &y2, &x, &y, &x0, &y0) != EOF) { if (m > 0 && n > 0 && m <= 9 &&n<=9) { printf("0\n"); } else { printf("-1\n"); } if (x1 >= 0 && x1 <= m - 1 && y1 >= 0 && y1 <= n - 1 && x2 >= 0 && x2 <= m - 1 && y2 >= 0 && y2 <= n - 1) { printf("0\n"); } else { printf("-1\n"); } if (x >= 0 && x <= m - 1 && m <= 8&&m>0 ) { printf("0\n"); } else { printf("-1\n"); } if( y >= 0 && y <= n - 1 && n <= 8&&n>0) { printf("0\n"); } else { printf("-1\n"); } if (x0 >= 0 && x0 <= m - 1 && y0 >= 0 && y0 <= n - 1) { printf("0\n"); } else { printf("-1\n"); } } return 0; }