标签:pre int col 数组 span 矩阵 div 设置 range
arrA=[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]] N=4 #声明4x4数组arr arrB=[[None] * N for row in range(N)] print(‘[原设置的矩阵内容]‘) for i in range(4): for j in range(4): print(‘%d‘ %arrA[i][j],end=‘\t‘) print() #进行矩阵转置的操作 for i in range(4): for j in range(4): arrB[i][j]=arrA[j][i] print(‘[转置矩阵的内容为]‘) for i in range(4): for j in range(4): print(‘%d‘ %arrB[i][j],end=‘\t‘) print()
输出
[原设置的矩阵内容] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [转置矩阵的内容为] 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16
标签:pre int col 数组 span 矩阵 div 设置 range
原文地址:https://www.cnblogs.com/sea-stream/p/10016526.html