题解 | #二维数组操作#
二维数组操作
https://www.nowcoder.com/practice/2f8c17bec47e416897ce4b9aa560b7f4
while True:
try:
m, n = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
xAdd = int(input())
yAdd = int(input())
xChk, yChk = map(int, input().split())
print(0 if m <= 9 and n <= 9 else -1)
print(0 if x1 < m and y1 < n and x2 < m and y2 < n else -1)
print(0 if xAdd < m and m < 9 else -1)
print(0 if yAdd < n and n < 9 else -1)
print(0 if xChk < m and yChk < n else -1)
except:
break
其实只要注意到题面中的 “2.对于插入操作,如果插入后行数或列数超过9了则应返回错误。如果插入成功了则将数据表恢复至初始化的 大小,多出的数据则应舍弃。” ,则可知道其实插入操作完成之后并不会对
或
的值产生影响,因而可以得出上述代码的做法。
查看7道真题和解析
