2019-旋转
题目
题解
- 画出二维矩阵,找规律,注意输入,输出
n, m = map(int, input().split())#读入n,m
a = []
for i in range(n):#读入二维数组
a.append(list(map(int, input().split()))) # a是n*m的矩阵
b = [[0]*n for i in range(m)] #创建一个旋转之后m*n的矩阵
for i in range(n):
for j in range(m):
b[j][n-i-1] = a[i][j] #把值填入旋转之后的矩阵
for i in range(m): #打印结果
for j in range(n):
print(b[i][j], end=' ')
print()