[프로그래머스] 행렬의곱셈

leejihun·2022년 6월 18일
0

알고리즘

목록 보기
29/50

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) 
{
    vector<vector<int>> answer;
    int Row = arr1.size();
    int Col = arr1[0].size();
    int Row2 = arr2.size();
    int Col2 = arr2[0].size();
    
    for(int i = 0 ; i < Row ; i++)
    {
        vector<int> V;
        for(int j = 0 ; j < Col2 ; j++)
        {
            int Sum = 0;
            for(int k = 0 ; k < Row2; k++)
            {
                Sum += arr1[i][k] * arr2[k][j];
            }
            V.push_back(Sum);
        }
        answer.push_back(V);
    }
    return answer;
}

https://yabmoons.tistory.com/700

profile
U+221E

0개의 댓글