본문 바로가기

Algorithm

(C++) - 백준(BOJ) 2738번 : 행렬 덧셈

반응형
#include <iostream>
using namespace std;
int a[101][101], b[101][101],n,m;
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> b[i][j];
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
            cout << a[i][j] + b[i][j] << ' ';
        cout << '\n';
    }
}