求矩阵A*B,得到的结果C
得到矩阵C
A=[[1,1,1],[2,2,2],[3,3,3]]
B=[[1,0,0],[0,1,0],[0,0,1]]
c=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
for j in range(3):
for k in range(3):
c[i][j] += A[i][k]*B[k][j]
输出矩阵C
for i in range(3):
for j in range(3):
if (j+1)%3 == 0 and (i+1)%3 != 0:
print(c[i][j],end=' ')
print()
continue
print(c[i][j],end=' ')