1)通过list(map(int,iterable))将矩阵以二维列表的形式导入。这里必须在map()外面加层list()
2)通过两层for循环遍历计算两个举证相乘。
a_x,a_y,c_y = int(input()),int(input()),int(input())
a1=[]
a2 = []
for i in range(a_x):
a1.append(list(map(int,input().split(' '))))
for i in range(a_y):
a2.append(list(map(int,input().split(' '))))
b_list = []
for a in range(a_x):
x_list = []
for c in range(c_y):
x = a1[a][0]*a2[0][c]+a1[a][1]*a2[1][c]+a1[a][2]*a2[2][c]
x_list.append(x)
b_list.append(x_list)
for m in b_list:
for n in m:
print(n,end=' ')
print()

京公网安备 11010502036488号