标签:
Description
Input
Output
Sample Input
dog ogday cat atcay pig igpay froot ootfray loops oopslay atcay ittenkay oopslay
Sample Output
cat eh loops
Hint
1 #include <iostream> 2 #include <map> 3 #include <cstring> 4 #include <string> 5 #include <cstdio> 6 using namespace std; 7 char s[30], s1[15], s2[15]; 8 string s3, tmp; 9 map <string, string> mp; 10 map <string, string> :: iterator it; 11 int main() 12 { 13 while(gets(s)&&strlen(s)) 14 { 15 sscanf(s, "%s %s", s1, s2); 16 mp[s2] = s1; 17 } 18 while(cin >> s3) 19 { 20 it = mp.find(s3); 21 if(it == mp.end()) 22 cout <<"eh"<< endl; 23 else 24 cout <<it ->second << endl; 25 } 26 }
1 #include<iostream> 2 #include<cstdio> 3 #include<map> 4 #include<cstring> 5 using namespace std; 6 int main() 7 { 8 string s; 9 map<string,string>Q; 10 while(getline(cin,s)&&s.length()!=0) 11 { 12 int blank=s.find(‘ ‘);//урЁЖ©у╦Я╣дн╩жц 13 string x=s.substr(0,blank); 14 string y=s.substr(blank+1); 15 Q[y]=x; 16 } 17 string z; 18 while(cin>>z) 19 { 20 if((Q[z].length())==0) 21 cout<<"eh"<<endl; 22 else 23 cout<<Q[z]<<endl; 24 } 25 return 0; 26 }
标签:
原文地址:http://www.cnblogs.com/Aa1039510121/p/5692933.html