#include <stdio.h>
#include <stdlib.h>

int main() {
    int n,m;
    
    scanf("%d %d", &n, &m);

    int a;
    
    int** arr1 = (int**)malloc(sizeof(int*)*n);
    for(int i=0; i<n; i++){
        arr1[i] = (int*)malloc(sizeof(int)*m);
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            scanf("%d", &a);
            arr1[i][j] = a;
        }
    }

    int** arr2 = (int**)malloc(sizeof(int*)*n);
    for(int i=0; i<n; i++){
        arr2[i] = (int*)malloc(sizeof(int)*m);
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            scanf("%d", &a);
            arr2[i][j] = a;
        }
    }

    int** arr3 = (int**)malloc(sizeof(int*)*n);
    for(int i=0; i<n; i++){
        arr3[i] = (int*)malloc(sizeof(int)*m);
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            arr3[i][j] = arr1[i][j] + arr2[i][j];
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            printf("%d ", arr3[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}

Embed on website

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