题解 | #二维数组操作#
二维数组操作
https://www.nowcoder.com/practice/2f8c17bec47e416897ce4b9aa560b7f4
while True:
try:
m,n = map(int,input().strip().split())
x1,y1,x2,y2 = map(int,input().strip().split())
insert_row = int(input())
insert_col = int(input())
SearchX,SearchY = map(int,input().strip().split())
if (0 <= m <= 9) and (0 <= n <= 9):
print(0)
else:
print(-1)
if (0 <= x1 < m) and (0 <= y1 < n) and (0 <= x2 < m) and (0 <= y2 < n):
print(0)
else:
print(-1)
if (0 <= insert_row < m) and ( m < 9):
print(0)
else:
print(-1)
if (0 <= insert_col< n) and ( n < 9):
print(0)
else:
print(-1)
if (0 <= SearchX < m) and (0 <= SearchY < n):
print(0)
else:
print(-1)
except:
break
主要是理清题目意思,输入m,n = map(int,input().strip().split())
x1,y1,x2,y2 = map(int,input().strip().split())
insert_row = int(input())
insert_col = int(input())
SearchX,SearchY = map(int,input().strip().split())
然后对每一行中的输入值进行限制范围,注意索引范围是0~m-1 or n-1的,但m、n是在0~9之间
查看17道真题和解析