输入有多组数据。 每组输入一个5 * 5的数组,然后输入一行,这一行有四个数,前两个代表操作类型,后两个数x y代表需操作数据为以x y为左上角的那几个数据。
输出翻转后的数组。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 3 1 1
11 6 1 4 5 12 7 2 9 10 13 8 3 14 15 16 17 18 19 20 21 22 23 24 25
while True:
try:
c = []
for _ in range(5):
c.append(list(input().split()))
b = list(map(int,input().split()))
x = b[2] - 1
y = b[3] - 1
if b[0] == 1 and b[1] == 2:
c[x][y],c[x][y+1],c[x+1][y+1],c[x+1][y] = c[x+1][y],c[x][y],c[x][y+1],c[x+1][y+1]
elif b[0] == 1 and b[1] == 3:
c[x][y],c[x][y+1],c[x][y+2],c[x+1][y+2],c[x+2][y+2],c[x+2][y+1],c[x+2][y],c[x+1][y]\
= c[x+2][y],c[x+1][y],c[x][y],c[x][y+1],c[x][y+2],c[x+1][y+2],c[x+2][y+2],c[x+2][y+1]
elif b[0] == 2 and b[1] == 2:
c[x][y],c[x][y+1],c[x+1][y+1],c[x+1][y] = c[x][y+1],c[x+1][y+1],c[x+1][y],c[x][y]
else:
c[x][y],c[x][y+1],c[x][y+2],c[x+1][y+2],c[x+2][y+2],c[x+2][y+1],c[x+2][y],c[x+1][y]\
= c[x][y+2],c[x+1][y+2],c[x+2][y+2],c[x+2][y+1],c[x+2][y],c[x+1][y],c[x][y],c[x][y+1]
for i in c:
print(' '.join(map(str,i)))
except:
break def one(x,y,index):
list1=[]
for j in range(y-1,y-1+index):
re=[]
for i in range(x-1,x-1+index):
re.append(arr[i][j])
list1.append(re[::-1])
for i in range(x-1,x-1+index):
for j in range(y-1,y-1+index):
arr[i][j]=list1[i-x+1][j-y+1]
def two(x,y,index):
list1=[]
for j in range(y-2+index,y-2,-1):
re=[]
for i in range(x-1,x-1+index):
re.append(arr[i][j])
list1.append(re)
for i in range(x-1,x-1+index):
for j in range(y-1,y-1+index):
arr[i][j]=list1[i-x+1][j-y+1]
while True:
try:
arr=[]
for i in range(5):
arr.append(list(input().strip().split(' ')))
inp=list(map(int,input().strip().split(' ')))
if [inp[0],inp[1]]==[1,2]:
one(inp[2],inp[3],2)
elif [inp[0],inp[1]]==[1,3]:
one(inp[2],inp[3],3)
elif [inp[0],inp[1]]==[2,2]:
two(inp[2],inp[3],2)
else:
two(inp[2],inp[3],3)
for i in arr:
print(' '.join(i))
except:
break