题解 | #矩阵乘法#

矩阵乘法

http://www.nowcoder.com/practice/ebe941260f8c4210aa8c17e99cbc663b

暴力破解

while True:
    try:
        x = int(input())
        y = int(input())
        z = int(input())
        result1 = []
        result2 = []
        res = []
        for j in range(x):
            result1.append(list(map(int, input().split(' '))))
        for k in range(y):
            result2.append(list(map(int, input().split(' '))))
        for i in range(len(result1)):
            for j in range(z):
                a = 0
                for k in range(y):
                    a += result1[i][k]*result2[k][j]
                res.append(a)
        for i in range(0, len(res)):
            endl = "\n" if (i+1)%z == 0 else " "
            print(res[i], end = endl)
    except:
        break
全部评论

相关推荐

扭转乾坤_:现在企业都是学华为,一直通过丢池子里,最后捞
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务