两个矩阵相乘——今天笔试题全崩啦
import numpy as np
arr=input()
num=[int(n) for n in arr.split()]
print(num)
line=[[0]*num[1]]*num[0]
line2=[[0]*num[2]]*num[1]
for i in range(num[0]):
line[i]=input().split()
line[i]=[int(j) for j in line[i]]
print(line)
for i in range(num[1]):
line2[i]=input().split()
line2[i]=[int(j) for j in line2[i]]
print(line2)
print(np.dot(line,line2))
import numpy as np
arr=input()
num=[int(n) for n in arr.split()]
print(num)
line=[[0]*num[1]]*num[0]
line2=[[0]*num[2]]*num[1]
for i in range(num[0]):
line[i]=input().split()
line[i]=[int(j) for j in line[i]]
print(line)
for i in range(num[1]):
line2[i]=input().split()
line2[i]=[int(j) for j in line2[i]]
print(line2)
print(np.dot(line,line2))
2020-09-08
在牛客打卡3天,今天也很努力鸭!
全部评论
相关推荐
点赞 评论 收藏
分享