#include <iostream>

using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    int a[n][m];
    int b[n][m];
    int ab[n][m];
    for(int i = 0;i< n;i++){
        for(int j = 0;j < m;j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0;i< n;i++){
        for(int j = 0;j < m;j++){
            cin >> b[i][j];
        }
    }
    for(int i = 0;i< n;i++){
        for(int j = 0;j < m;j++){
            ab[i][j] = a[i][j]+b[i][j];
        }
    }
    for(int i = 0;i< n;i++){
        for(int j = 0;j < m;j++){
            cout << ab[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: