Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- // Выделение памяти
- int w, h, wcopy, hcopy;
- scanf("%d%d", &w, &h);
- wcopy = w;
- hcopy = h;
- char **pict_1;
- pict_1 = (char **) malloc(h * sizeof(char *));
- for (int i = 0; i < h; i++) pict_1[i] = (char *) malloc(w * sizeof(char));
- char **pict_2;
- pict_2 = (char **) malloc(h * sizeof(char *));
- for (int i = 0; i < h; i++) pict_2[i] = (char *) malloc(w * sizeof(char));
- char **pict_3;
- pict_3 = (char **) malloc(h * sizeof(char *));
- for (int i = 0; i < h; i++) pict_3[i] = (char *) malloc(w * sizeof(char));
- // Считывание данных
- for (int i = 0; i < h; i++) scanf("%s", pict_1[i]);
- for (int i = 0; i < h; i++) scanf("%s", pict_2[i]);
- char logic[4];
- scanf("%s", logic);
- // MAIN LOOP
- for (int i = 0; i < hcopy; i++) {
- for (int j = 0; j < wcopy; j++) {
- if (pict_1[i][j] == '0') {
- if (pict_2[i][j] == '0') pict_3[i][j] = logic[0];
- else pict_3[i][j] = logic[1];
- } else {
- if (pict_2[i][j] == '0') pict_3[i][j] = logic[2];
- else pict_3[i][j] = logic[3];
- }
- }
- }
- for (int i = 0; i < hcopy; i++) {
- for (int j = 0; j < wcopy; j++) printf("%c", pict_3[i][j]);
- if (i < hcopy - 1) printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement