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 |
Re:map写着很happy呀……In Reply To:map写着很happy呀…… Posted by:anyl94xh at 2011-10-20 15:50:26 > //除了时间有点…… > #include<iostream> > #include<string> > #include<map> > using namespace std; > map<string,string> rule; > int main() > { > int cur,len; > string s,s1,s2; > while(getline(cin,s)) > { > if((cur=s.find(' '))!=string::npos) > { > len=s.length(); > s1=s.substr(0,cur); > s2=s.substr(cur+1,len); > rule[s2]=s1; > } > else > { > if(s=="") continue; > if(rule[s]!="") cout<<rule[s]<<endl; > else cout<<"eh\n"; > } > } > return 0; > } 其实从s==“”跳出再来个while用于输出的,不每次find(‘ ’)就快点了。。。 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator