#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
using namespace std;
#define N 300
char Find[100000][N];
char Replace[100000][N];
int main()
{
int n;
while(~scanf("%d", &n))
{
getchar();
if(!n)
break;
char tmp[N];
for(int i = 0; i < n; i++)
{
gets(tmp); strcpy(Find[i], tmp);
gets(tmp);
if(tmp[0]=='\n')
Replace[i][0]==-1;
else
strcpy(Replace[i], tmp);
}
char a[N];
gets(a); int len = strlen(a);
for(int i = 0; i < n; i++)
{
int j = 0;
while(j<len)
{
if(Find[i][0]==a[j])
{
int len2 = strlen(Find[i]);
int k;
for(k = 0; k < len2; k++)
if(Find[i][k]!=a[j+k])
break;
if(k==len2)
{
for(k = 0; k < j; k++)
tmp[k] = a[k];
if(Replace[i][0]!=-1)
for(int g = 0; g < strlen(Replace[i]); g++)
tmp[k++] = Replace[i][g];
for(int g = j+len2; g < len; g++)
tmp[k++] = a[g];
tmp[k] = '\0';
//printf("tmp = %s\n", tmp);
strcpy(a, tmp);
len = strlen(a);
j = -1;
}
}
j++;
}
}
printf("%s\n", a);
}
return 0;
}
uva10115 Automatic Editing
最新推荐文章于 2021-07-28 20:05:23 发布