原题链接:
https://vjudge.net/problem/UVA-10115#author=Luke
AC代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while (cin >> n && n != 0)
{
string s1[20];
string s2[20];
getchar();
for (int i = 0; i < n; i++)
{
getline(cin, s1[i]);
getline(cin, s2[i]);
}
string str;
getline(cin, str);
for (int i = 0; i < n; i++)
{
int index = 0;
index = str.find(s1[i]);
while (index != str.npos)
{
str = str.replace(index, s1[i].length(), s2[i]);
index = str.find(s1[i]);
}
}
cout << str << endl;
}
return 0;
}