Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <math.h>
- #include <string.h>
- #define EPS 1e-8
- #define pi 3.1415926535897932384626433832795028841971693993751
- #define N 2147483647
- int t, i, j, k, l, a, b, c, d, x, y, z, flag, flag2, len, len2, n, m, p;
- char ch, str[1000][1000], str2[1000][1000], str3[10000], str4[10000], str5[10000];
- char *ptr, *pch;
- int main()
- {
- /*freopen("sample.txt", "r", stdin);*/
- for (; ;)
- {
- scanf("%d", &n);
- scanf("%c", &ch);
- if (n == 0) break;
- for (j = 0; j < n; j++)
- {
- gets(str[j]);
- gets(str2[j]);
- }
- gets(str4);
- for (j = 0; j < n;)
- {
- pch = strstr(str4, str[j]);
- if (pch != '\0')
- {
- l = 0;
- for (ptr = str4; ptr < pch; ptr++)
- {
- str3[l] = *ptr;
- l++;
- }
- len = strlen(str2[j]);
- for (k = 0; k < len; k++)
- {
- str3[l] = str2[j][k];
- l++;
- }
- len = strlen(str[j]);
- for (ptr = pch + len; *ptr != '\0'; ptr++)
- {
- str3[l] = *ptr;
- l++;
- }
- str3[l] = '\0';
- strcpy(str4, str3);
- }
- else
- {
- j++;
- }
- }
- printf("%s\n", str4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement