https://programmers.co.kr/learn/courses/30/lessons/12949
#include <string>
#include <vector>
using namespace std;
vector<vector<int>> solution(vector<vector<int>> arr1, vector<vector<int>> arr2) {
int row = arr1.size();
int column = arr2[0].size();
vector<vector<int>> answer(row, vector<int>(column, 0));
for(int k=0; k < row;k++){
for(int j=0;j < column; j++){
int sum =0;
for(int i=0;i<arr2.size();i++){
sum += arr1[k][i] * arr2[i][j];
}
answer[k][j] = sum;
}
}
return answer;
}
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int> >productMatrix(vector<vector<int> >A, vector<vector<int> >B)
{
int Acol = A[0].size();
int Arow = A.size();
int Brow = B.size();
int Bcol = B[0].size();
vector<vector<int> >answer(Arow, vector<int>(Bcol));
if (Acol == Brow) {
for (int i = 0; i < Arow; i++) {
for (int j = 0; j < Bcol; j++) {
answer[i][j] = 0;
for (int k = 0; k < Acol; k++) {
answer[i][j] += A[i][k]*B[k][j];
}
}
}
}
return answer;
}
int main()
{
vector<vector<int> >A{ { 1,2 },{ 2,3 } };
vector<vector<int> >B{ { 2,3 },{ 3,4 } };
vector<vector<int> > testAnswer = productMatrix(A, B);
for (int i = 0; i<testAnswer.size(); i++)
{
for (int j = 0; j<testAnswer[i].size(); j++)
cout << testAnswer[i][j] << " ";
cout << "\n";
}
}