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 |
给我一个WA的理由!!!!Source Problem Id:2803 User Id:qiqilrq Memory:208K Time:0MS Language:G++ Result:Wrong Answer Source //string manipulate #include <iostream> #include <map> #include <string> using namespace std; const string P[2][5]={{"anti", "post", "pre", "re", "un"}, {"against *", "after *", "before *", "* again", "not *"} }; const string S[2][5]={{"er","ing","ize","s","tion"}, {"one who *s", "to actively *", "change into *","multiple instances of *","the process of *ing"} }; void printsuf(string s){ int si; for(si=0; si<5; ++si) { int p = s.find(S[0][si]); if(p>=0 && p == s.length() - S[0][si].length()) { // cut off the suffix string ss(&s[0], &s[p]); string ps = S[1][si]; for(int i=0; i<ps.length(); i++) { if(ps[i]=='*') cout<<ss; else cout<<ps[i]; } return ; } } cout<<s; } void print(string s){ int pi; for(pi=0; pi<5; ++pi) { if(s.find(P[0][pi]) == 0) { // cut off the prefix string ss = &s[P[0][pi].length()]; string ps = P[1][pi]; for(int i = 0; i<ps.length(); i++) { if(ps[i]=='*') printsuf(ss); else cout<<ps[i]; } return ; } } printsuf(s); } int main() { int n; string str; cin>>n; while(n--){ cin>>str; print(str); cout<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator