题解 | #矩阵乘法#
矩阵乘法
http://www.nowcoder.com/practice/ebe941260f8c4210aa8c17e99cbc663b
//无脑for循环 #include <iostream> using namespace std; int a[100][100] = {0}, b[100][100] = {0}, c[100][100] = {0}; //c = a*b int x,y,z; int main() { cin>>x>>y>>z; for(int i = 0; i < x; i++) for(int j = 0; j < y; j++) scanf("%d",&a[i][j]); for(int i = 0; i < y; i++) for(int j = 0; j < z; j++) scanf("%d",&b[i][j]); for(int i = 0; i < x; i++) for(int j = 0; j < z; j++) for(int k = 0; k < y; k++) c[i][j] += a[i][k]*b[k][j]; for(int i = 0; i < x; i++) { for(int j = 0; j < z; j++) cout << c[i][j]<<' '; cout << endl; } return 0; }