1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #include <stdio.h> #pragma warning(disable:4996) int n, t; typedef struct _changer { char a; char b; }changer; changer list[52]; char answer[100005]; int main() { int i = 1; char dir, tmp; FILE *fin = fopen("input.txt", "rt"); FILE *fout = fopen("output.txt", "wt"); // 입력 fscanf(fin, "%d", &n); fscanf(fin, "%c", &tmp); // enter for (int i = 1; i <= n; i++) fscanf(fin, "%c %c ", &list[i].a, &list[i].b); fscanf(fin, "%d", &t); fscanf(fin, "%c", &tmp); // enter a: for (i; i <= t;) { fscanf(fin, "%c", &dir); fscanf(fin, "%c", &tmp); // enter for (int j = 1; j <= n; j++) { if (list[j].a == dir) { answer[i] = list[j].b; i++; goto a; } } answer[i] = dir; i++; } // 출력 for (int i = 1; i <= t; i++) fprintf(fout, "%c", answer[i]); fprintf(fout, "\n"); } |