hdu 1075 What Are You Talking About
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075
题目大意:给出一个“翻译-原文”的对应表,然后给出句子,要把句子中的原文都翻译出来
代码:
#include<bits/stdc++.h> using namespace std; map<string,string>word; char s[5000]; int main() { string s1,s2,a; cin>>a; while(cin>>s1) { if(s1=="END") break; else { cin>>s2; word[s2]=s1; } } cin>>a; getchar(); while(1) { gets(s); if(strcmp(s,"END")==0) break; int len=strlen(s); a=""; for(int i=0;i<len;i++) { if(islower(s[i])) a+=s[i]; else { if(word.find(a)!=word.end()) cout<<word[a]; else cout<<a; a=""; cout<<s[i]; } } cout<<endl; } return 0; }
anytime you feel the pain.hey,refrain.don't carry the world upon your shoulders