题解 | #矩阵乘法#
矩阵乘法
https://www.nowcoder.com/practice/ebe941260f8c4210aa8c17e99cbc663b
新思路
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { // Write your code here let a1 = await readline() let a2 = await readline() let a3 = await readline() let arr1 = [],arr2 = [] for(let i = 0;i<a1;i++){ arr1.push((await readline()).split(" ").map(v => +v)) } for(let i = 0;i<a2;i++){ arr2.push((await readline()).split(" ").map(v => +v)) } let add = [] for(let i = 0;i<arr1.length;i++){ let sumArr = [] for(let j = 0;j<arr2[0].length;j++){ let sum = 0; sum = arr1[i].reduce((pre,cur,k) => pre = pre +cur*arr2[k][j],0) sumArr.push(sum) } add.push(sumArr) } add.forEach(v => console.log(v.join(" "))) }()