7-7 方阵循环右移
时间: 2024-01-28 11:12:41 浏览: 89
C语言实现方阵循环右移算法(含算法实现原理)
```python
def rotate_matrix(matrix, n):
for i in range(n):
for j in range(n-1, -1, -1):
if j != 0:
print(matrix[j][i], end=' ')
else:
print(matrix[j][i])
# 读取输入
m, n = map(int, input().split())
matrix = [list(map(int, input().split())) for _ in range(n)]
# 旋转方阵
rotate_matrix(matrix, n)
```
阅读全文