#include <stdio.h>
#include <string.h>
int main() {
char str[30][300], str1[700], str2[700];
int n;
while (scanf("%d", &n) && n != 0) {
getchar();
for (int i = 0; i < n*2; i++)
gets(str[i]);
gets(str1);
strcpy(str2, str1);
int len = strlen(str1), i, j, k_1, m = 0, k, s, len_1, len_2, l;
for (j = 0; j < n*2; j += 2) {
for (i = 0; i < len; i++) {
len_1 = strlen(str[j]);
k = i, s = 0;
k_1 = i;
while (str1[k] == str[j][s]) {
k++, s++;
if (s == len_1) {
len_2 = strlen(str[j+1]);
while (k_1 < len) {
str1[k_1 + len_2] = str2[k_1 + len_1];
k_1++;
}
strcpy(str2, str1);
l = 0;
while (l < len_2) {
str1[i+l] = str[j+1][l];
l++;
}
strcpy(str2, str1);
i = 0;
len = len + len_2 - len_1;
}
}
}
}
puts(str1);
}
return 0;
}
UVA 10115 (暑假-字符串(2) -F - Automatic Editing)
最新推荐文章于 2017-09-06 15:20:39 发布