본문 바로가기

코딩테스트/프로그래머스

[Level 1][C++] 행렬의 덧셈

#include <string>
#include <vector>

using namespace std;

vector<vector<int>> solution(vector<vector<int>> arr1, vector<vector<int>> arr2) {
    vector<vector<int>> answer(arr1);
    
    for(int i=0; i<arr1.size(); i++)
        for(int j=0; j<arr1[i].size(); j++)
            answer[i][j] += arr2[i][j];
    
    return answer;
}