【王道机试】-矩阵-矩阵乘法-哈尔滨工业大学
作者:互联网
求矩阵乘法还挺有意思的
//#include "pch.h"
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<vector<int>> num1(2, vector<int>(3));
vector<vector<int>> num2(3, vector<int>(2));
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
cin >> num1[i][j];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 2; j++)
cin >> num2[i][j];
vector<vector<int>> res(2, vector<int>(2));
for (int i = 0; i < 2; i++)//ik作为数组a//kj作为数组b//ij作为数组c
for (int j = 0; j < 2; j++)
for (int k = 0; k < 3; k++)
res[i][j] += num1[i][k] * num2[k][j];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
cout << res[i][j] << " ";
}
cout << endl;
}
}
标签:哈尔滨工业大学,num2,int,矩阵,++,vector,机试,include,num1 来源: https://blog.csdn.net/qq_39328436/article/details/114755575