C++:: 프로그래머스 < 행렬의 덧셈 >

jahlee·2023년 7월 31일
0

프로그래머스_Lv.1

목록 보기
49/75
post-thumbnail

제목 그대로 행렬의 덧셈을 반환해주면 되는 간단한 문제이다.

#include <string>
#include <vector>

using namespace std;

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

0개의 댓글