| ||||||||||
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:STL首题,感觉有点大材小用了In Reply To:STL首题,感觉有点大材小用了 Posted by:abilitytao at 2008-09-30 15:41:21 > #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; > } > > 虽然我还没有写出来,但是感觉用stl有点把简单问题复杂化 > > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator