题解 | #二维数组操作#

二维数组操作

http://www.nowcoder.com/practice/2f8c17bec47e416897ce4b9aa560b7f4

while True:
    try:
        # 初始化表格
        m, n = map(int, input().split())
        if m > 9 or n > 9:
            print('-1')
        else:
            print('0')
        
        # 交换坐标
        x1, y1, x2, y2 = map(int, input().split())
        if 0 <= x1 < m and 0 <= x2 < m and 0 <= y1 < n and 0 <= y2 < n:
            print('0')
        else:
            print('-1')
        
        # 插入行
        x = int(input())
        if m < 9 and 0 <= x < m:
            print('0')
        else:
            print('-1')
        
        # 插入列
        y = int(input())
        if n < 9 and 0 <= y < n:
            print('0')
        else:
            print('-1')
        
        # 查找坐标
        x, y = input().split()
        x, y = int(x), int(y)
        if 0 <= x < m and 0 <= y < n:
            print('0')
        else:
            print('-1')

    except EOFError:
        break
    

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
1 1 评论
分享
牛客网
牛客企业服务