题解 | #矩阵乘法#
矩阵乘法
http://www.nowcoder.com/practice/ebe941260f8c4210aa8c17e99cbc663b
while(line = readline()) {
let x = parseInt(line);
let y = parseInt(readline());
let z = parseInt(readline());
let A = [];
let B = [];
let C = Array(x).fill(0).map(x => Array(z).fill(0));
for (let i=0; i< x;i++) {
A.push(readline());
}
for (let i=0; i< y;i++) {
B.push(readline());
}
A = A.map(
x => x.split(' ').map(
x => parseInt(x)
));
B = B.map(
x => x.split(' ').map(
x => parseInt(x)
));;
for(let i=0; i<x; i++) {
for (let j=0; j<z; j++) {
for(let k=0; k< y; k++) {
C[i][j] += A[i][k] * B[k][j];
}
}
}
for(let item of C) {
print(item.join(' '));
}
}