完成一个4*6的矩阵逆序用Python写
时间: 2023-05-19 13:06:44 浏览: 81
python求矩阵的逆
可以使用Python的列表和循环来实现矩阵逆序。以下是一个示例代码:
matrix = [[1, 2, 3, 4, 5, 6],
[7, 8, 9, 10, 11, 12],
[13, 14, 15, 16, 17, 18],
[19, 20, 21, 22, 23, 24]]
for row in matrix:
row.reverse()
matrix.reverse()
print(matrix)
输出结果为:
[[24, 23, 22, 21, 20, 19],
[18, 17, 16, 15, 14, 13],
[12, 11, 10, 9, 8, 7],
[6, 5, 4, 3, 2, 1]]
阅读全文