题解 | #二维数组操作#
二维数组操作
https://www.nowcoder.com/practice/2f8c17bec47e416897ce4b9aa560b7f4
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
//其实这题就是考阅读理解
int m = in.nextInt();
int n = in.nextInt();
int r1 = (m >= 0 && m <= 9) && (n >= 0 && n <= 9) ? 0 : -1;
int x1 = in.nextInt();
int y1 = in.nextInt();
int x2 = in.nextInt();
int y2 = in.nextInt();
int r2 = (x1 >= 0 && x1 <= m - 1)
&& (x2 >= 0 && x2 <= m - 1)
&& (y1 >= 0 && y1 <= n - 1)
&& (y2 >= 0 && y2 <= n - 1) ? 0 : -1;
int row = in.nextInt();
int r3 = (m >= 0 && m < 9) && (row >= 0 && row <= m - 1) ? 0 : -1;
int col = in.nextInt();
int r4 = (n >= 0 && n < 9) && (col >= 0 && col <= n - 1) ? 0 : -1;
int x = in.nextInt();
int y = in.nextInt();
int r5 = (x >= 0 && x <= m - 1) && (y >= 0 && y <= n - 1) ? 0 : -1;
System.out.println(r1 + "\n" + r2 + "\n" + r3 + "\n" + r4 + "\n" + r5);
}
}
}
网易游戏公司福利 555人发布