プログラママトリクスの積(Lv 2)


#include <string>
#include <vector>

using namespace std;

vector<vector<int>> solution(vector<vector<int>> arr1, vector<vector<int>> arr2) {
    vector<vector<int>> answer;
    vector<int> TempContainer;
    
 
	for (int i = 0; i < arr1.size(); i++)//행렬 [ 3 by 2 ] * [2 by 4 ] 앞행렬 3에 해당됨  
	{
		for (int j = 0; j < arr2[0].size(); j++)//행렬 [ 3 by 2 ] * [2 by 4 ] 뒷행렬 3에 해당됨  곱셈 후[ 3 by 4 ]생성
		{
			int Temp = 0;
			for (int k = 0; k < arr2.size(); k++)
			{
				Temp += arr1[i][k] * arr2[k][j];//[ 3 by 4 ]에서 각각 만들어내는 방법(행렬계산법임)
			}
			TempContainer.push_back(Temp);//템프 컨테이너에 담아내고
		}
		answer.push_back(TempContainer);//
		TempContainer.clear();//이부분 clear 해줘야한다.
	}
	return answer;
}
2 Dマトリクスにはすでにある程度熟練している.
詳細はコメントで処理します.