用map做的,
#include <iostream>
#include <map>
#include <string>
#include <cctype>
using namespace std;
map<string ,string> m;
int main()
{
string mar,earth,s;
cin>>s;
while(cin>>earth)
{
if(earth=="END")
break;
cin>>mar;
m[mar]=earth;
}
getchar();
string str,code;
int i,j;
while(getline(cin,str))
{
code="";
if(str=="END") break;
if(str=="START") continue;
for(i=0;i<str.size();i++)
{
if(isalpha(str[i]))
{
code+=str[i];
if(!isalpha(str[i+1]))
{
if(m[code]!="")
cout<<m[code];
else
cout<<code;
code="";
}
}
else
cout<<str[i];
}
cout<<endl;
}
return 0;
}