#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; const int maxn = 100; struct mat{ int m[maxn][maxn]; int row; int col; }; mat operator * (mat a, mat b){ mat ret; ret.row = a.row; ret.col = b.col; int n = a.col; for(int i = 0; i < a.row; i++){ for(int j = 0; j < b.col; j++){ int x = 0; for(int k = 0; k < n; k++){ x += a.m[i][k] * b.m[k][j]; } ret.m[i][j] = x; } } return ret; } int main(void){ mat a,b,c; a.row = 2; a.col = 3; b.row = 3; b.col = 2; while(cin >> a.m[0][0] >> a.m[0][1] >> a.m[0][2]){ for(int i = 1; i < a.row; i++){ for(int j = 0; j < a.col; j++){ cin >> a.m[i][j]; } } for(int i = 0; i < b.row; i++){ for(int j = 0; j < b.col; j++){ cin >> b.m[i][j]; } } c = a * b; for(int i = 0; i < c.row; i++){ for(int j = 0; j < c.col; j++){ cout << c.m[i][j] << " "; } cout << endl; } } return 0; }
0.0分
0 人评分