题解 | #矩阵乘法#

矩阵乘法

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

while True:
    try:
        x, y, z = int(input()), int(input()), int(input())
        lst1, lst2, lst3 = [], [], []
        for _ in range(x):
            lst1.append(list(map(int, input().split())))
        for _ in range(y):
            lst2.append(list(map(int, input().split())))
        for a in lst1:
            temp = []
            for i in range(z):
                b = []
                for elt in lst2:
                    b.append(elt[i])
                Sum = 0
                for pair in zip(a, b):
                    Sum += pair[0] * pair[1]
                temp.append(Sum)
            lst3.append(temp)
        for i in lst3:
            print(' '.join(map(str, i)))
    except:
        break
全部评论

相关推荐

06-27 15:29
门头沟学院 Java
点赞 评论 收藏
分享
牛客刘北:如果暑期实习是27届的话,你要晚一年才会毕业,企业为什么会等你呢?要搞清时间逻辑呀!27届现在实习只能是在暑假实习,这是日常实习,不是暑期实习。所以多去投日常实习吧,暑期实习肯定不会要你的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务