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 |
STL首题,感觉有点大材小用了#include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; int main () { vector<string>vect; string tem; int len; cin>>len; int count=0; int i; vector<string>::iterator beg; vector<string>::iterator end; for(i=0;i<len;i++) { cin>>tem; vect.push_back(tem); } while(!vect.empty()) { if(*vect.begin()<*(vect.end()-1)) { cout<<*(vect.begin()); vect.erase(vect.begin()); ++count; if(count%80==0) cout<<endl; continue; } if(*vect.begin()>*(vect.end()-1)) { cout<<*(vect.end()-1); vect.erase(vect.end()-1); ++count; if(count%80==0) cout<<endl; continue; } if(*vect.begin()==*(vect.end()-1)) { beg=vect.begin (); end=vect.end()-1; for(i=0;;i++) { ++beg; --end; if(beg>=end) { cout<<*vect.begin(); vect.erase(vect.begin()); ++count; break; } if(*beg<*end&&beg<end) { cout<<*vect.begin(); vect.erase(vect.begin()); ++count; break; } if(*beg>*end&&beg<end) { cout<<*(vect.end()-1); vect.erase(vect.end()-1); ++count; break; } if(*beg==*end&&beg<end) { continue; } } } if(count%80==0) 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