Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

神题,纯粹考察STL

Posted by speedcell4 at 2011-08-02 10:24:29 on Problem 1028
#include<iostream>
#include<string>
#include<stack>
using namespace std;
string a;
int main()
{
    stack<string> x;
    stack<string> y;
    x.push("http://www.acm.org/");
    while(cin>>a,a!="QUIT")
    {
        if(a=="VISIT")
        {
            cin>>a;
            x.push(a);
            while(!y.empty()) y.pop();
            cout<<a<<endl;
        }
        else if(a=="BACK")
        {
            a=x.top();x.pop();
            if(x.empty())
            {
                cout<<"Ignored"<<endl;
                x.push(a);
            }
            else
            {
                cout<<x.top()<<endl;
                y.push(a);
            }
        }
        else if(a=="FORWARD")
        {
            if(y.empty())
            {
                cout<<"Ignored"<<endl;
            }
            else
            {
                cout<<y.top()<<endl;
                x.push(y.top());
                y.pop();
            }
        }
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator