http://poj.org/problem?id=3253
就是一个哈夫曼树,题目下边有提示,所以题意还是好理解的
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
using namespace std;
int main ()
{
map<string, string> tra;
char s[], str[], s1[];
while (gets(s)&&s[])
{
sscanf(s,"%s %s",str,s1);//将输入的字符串,空格前边的赋给str串,后边的赋给s1串
tra.insert(pair<string,string>(s1,str));
}
while(cin>>str)
{
if (tra.find(str) != tra.end())
cout<<tra[str]<<endl;
else
cout<<"eh"<<endl;
}
return ;
}