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 ,0ms#include <string> #include <iostream> #include <vector> #include <list> #include <vector> #include <algorithm> #include <iostream> #include <map> #include <stack> using namespace std; int main() { stack<string> back; stack<string> forward; string tempt = "http://www.acm.org/"; string in; while(cin>>in) { if(in == "QUIT") break; if(in[0] == 'V') { cin>>in; back.push(tempt); tempt = in; cout<<tempt<<endl; while(forward.size() != 0) { forward.pop(); } } if( "BACK" == in) { if(back.size() == 0) { cout<<"Ignored"<<endl; } else { forward.push(tempt); tempt = back.top(); cout<<tempt<<endl; back.pop(); } } if(in == "FORWARD") { if(forward.size() == 0) { cout<<"Ignored"<<endl; } else { back.push(tempt); tempt = forward.top(); forward.pop(); cout<<tempt<<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