题解 | #二维数组操作#

二维数组操作

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了则应返回错误。如果插入成功了则将数据表恢复至初始化的 m*n 大小,多出的数据则应舍弃。” ,则可知道其实插入操作完成之后并不会对 mn 的值产生影响,因而可以得出上述代码的做法。

全部评论

相关推荐

砸砸无所畏惧:同字节耐面王 不同部门一起面了十几轮 最后放弃了 有个面试官透露面评都是算法能力不达预期
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务