#include<iostream> #include<vector> using namespace std; int main() { int x, y, z; cin >> x >> y >> z; int **m2 = new int*[y]; int **m1 = new int*[x]; int **m3 = new int*[x]; for (int i = 0; i < x; i++) { m1[i] = new int[y]; } for (int i = 0; i < y; i++) { m2[i] = new int[z]; } for (int i = 0; i < x; i++) { m3[i] = new int[z]; } //vector<int>m3; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { cin >> m1[i][j]; } } for (int i = 0; i < y; i++) { for (int j = 0; j < z; j++) { cin >> m2[i][j]; } } for (int i = 0; i < x; i++) { for (int j = 0; j < z; j++) { m3[i][j] = 0; } } for (int i = 0; i < x; i++) { for (int j = 0; j < z; j++) { for (int k = 0; k < y; k++) { m3[i][j] += m1[i][k] * m2[k][j]; } } } for (int i = 0; i<x; i++) { for (int j = 0; j<z - 1; j++) cout << m3[i][j] << " "; cout << m3[i][z - 1] << endl; } cout << endl; for (int i = 0; i < x; i++) { delete m1[i]; } for (int i = 0; i < y; i++) { delete m2[i]; } for (int i = 0; i < x; i++) { delete m3[i]; } return 0; }
不知道为什么只得到60分。