您的位置:首页 > 其它

hdu 1075 What Are You Talking About

2015-03-08 11:13 351 查看
#include <iostream>
#include <cstdio>
#include <string>
#include <map>

using namespace std;

int main()
{
map<string, string>th;
string a, b;
string::size_type i, len;
map<string, string>::iterator ite;

getline(cin, a);
th.clear();
while(1){
cin>>a;
if(a!="END"){
cin>>b;
th[b] = a;
}
else break;
}

/*for(ite=th.begin(); ite!=th.end(); ite++)
cout<<ite->first<<' '<<ite->second<<endl;*/

getline(cin, a);
getline(cin, a);
while(1)
{
getline(cin, a);
b.clear();
if(a!="END")
{
len = a.size();
for(i=0; i<len; i++)
{
if( isalpha(a[i]) )
b += a[i];
else{
if( b.empty()!=true )
{
if( th.count(b)!=0 )
cout<<th[b]<<a[i];
else
cout<<b<<a[i];  //注意输出a[i];
b.clear();          //注意清空b
}
else
cout<<a[i];
}
}
printf("\n");
}
else break;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: