Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int n, m;
- scanf("%d%d", &n, &m);
- int mat1[n][m], mat2[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &mat1[i][j]);
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &mat2[i][j]);
- }
- }
- int c[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- c[i][j] = 0;
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- int dali_go_ima = -1;
- for(int x = 0; x < n; x++) {
- for(int y = 0; y < m; y++) {
- if(mat1[i][j] == mat2[x][y]) {
- c[x][y] = mat1[i][j];
- dali_go_ima = 1;
- }
- }
- }
- if(dali_go_ima == -1) {
- c[i][j] = mat1[i][j];
- }
- }
- }
- printf("\n");
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- printf("%d ", c[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
- /*
- 3 3
- 2 3 7
- 3 1 4
- 2 1 8
- 6 2 7
- 3 1 4
- 2 9 6
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement