HJ69_矩阵乘法_数组
思路:
三层循环实现矩阵相乘。
import sys
a=[]
for line in sys.stdin:
a.append(list(map(int,line.strip().split())))
#print(a)
matrix1=a[3:3+a[0][0]]
matrix2=a[3+a[0][0]:]
nw=[[0 for i in range(a[2][0])]for i in range(a[0][0])]
for m in range(a[0][0]):
for n in range(a[2][0]):
for c in range(a[1][0]):
#print(m,n,c)
nw[m][n]=matrix1[m][c]*matrix2[c][n]+nw[m][n]
for i in nw:
print(" ".join(list(map(str,i))))