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:visual at 2006-04-08 12:37:57 > #include<iostream> > #include<stack> > #include<string> > #include<algorithm> > > using namespace std; > > int main() > { > int flag; > stack<string> back; > stack<string> next; > > string temp="http://www.acm.org/"; > string current; > while(getline(cin,current)) > { > if(current=="QUIT") > break; > > else if(current=="BACK") > { > if(back.empty()) > cout<<"Ignored"<<endl; > else > { > cout<<back.top()<<endl; > next.push(temp); > temp = back.top(); > back.pop(); > } > } > > else if(current=="FORWARD") > { > if(next.empty()) > cout<<"Ignored"<<endl; > else > { > cout<<next.top()<<endl; > back.push(temp); > temp = next.top(); > next.pop(); > } > } > > else if(flag=current.find("VISIT") != string::npos) > { > // cout<<flag<<endl; > flag = current.find_last_of(" ");//×¢ÒâŶÕâÀïµÄÓ÷¨£¡ > // cout<<flag<<endl; > back.push(temp); > temp = current.substr(flag+1) ; > while(!next.empty()) next.pop(); > > cout<<temp<<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