return matrix

Test cases

print(square_matrix_tranpose([[1,2,3],[4,5,6],[7,8,9]])) # [[1,4,7],[2,5,8],[3,6,9]] print(square_matrix_tranpose([[1,2],[3,4]])) # [[1,3],[2,4]] print(square_matrix_tranpose([[1,0,0],[0,1,0],[0,0,1]])) # [[1,0,0],[0,1,0],[0,0,1]] print(square_matrix_tranpose([[1,2],[3,4],[5,6]])) # [[1,3,5],[2,4,6]] print(square_matrix_tranpose([[1]])) # [[1]]

def square_matrix_tranposematrix for c in rangelenmatrix-1 for r in rangec+1lenmatrix matrixrcmatrixcr = matrixcrmatrixrc

原文地址: https://www.cveoy.top/t/topic/eGsj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录