Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
map水过,险些超时,贴个代码#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<map> using namespace std; int main() { int i; char str[15]; string str1,str2,s; map<string,string> m; while(gets(str) && strlen(str)) { str1=str2="\0"; for(i=0;;i++) if(str[i]==' ') { str[i]='\0'; break; } str1+=str; str2+=str+i+1; m[str2]=str1; } while(cin>>s) { if(m[s].size()) cout<<m[s]<<endl; else cout<<"eh\n"; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator