题解 | #二维数组操作#
二维数组操作
https://www.nowcoder.com/practice/2f8c17bec47e416897ce4b9aa560b7f4
while 1: try: size=input().split() m,n=int(size[0]),int(size[1]) if m>9 or n>9: print(-1) else: arr=[[0]*n]*m #print(arr) print(0) coord=input().split() x1,y1,x2,y2=int(coord[0]),int(coord[1]),int(coord[2]),int(coord[3]) if x1>m-1 or x2>m-1 or y1>n-1 or y2>n-1: print(-1) else: exchange=arr[x1][y1] arr[x1][y1]=arr[x2][y2] arr[x2][y2]=exchange print(0) x=int(input()) if m>8 or x>=m: print(-1) else: arr[x:x]=[[0]*n] #print(arr) print(0) #print(len(arr)) arr.pop() y=int(input()) if n>8 or y>=n: print(-1) else: for i in range(len(arr)): arr[i].insert(y,[]) arr[i].pop() #print(arr) print(0) coord1=input().split() x0=int(coord1[0]) y0=int(coord1[1]) if x0<m and y0<n: print(0) else: print(-1) except: break ''' l=[[1,2,3],[4,5,6],[7,8,9]] print(l[1][0:2],[i[0:2] for i in l]) l[0:0]=[[0,0,0]] print(l) for i in range(len(l)): l[i].append([]) l[i].insert(2,[]) l[0:4].insert(3,[]) # 错误 print(l) '''