POJ 1028 Web Navigation

Posted by 111qqz on Wednesday, July 8, 2015

TOC

http://poj.org/problem?id=1028

/* ***********************************************
Author :111qqz
Created Time :2016年02月19日 星期五 15时45分01秒
File Name :1028.cpp
************************************************ */

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
const int inf = 8E8;
stack<string> backstack;
stack<string> forwardstack;
string cur;
string cmd;
int main()
{
    cur ="http://www.acm.org/";

    while (cin>>cmd)
    {
        if (cmd=="QUIT")
        {
            break;
        }
        if (cmd=="BACK")
        {
            if (backstack.empty())
            {
                cout<<"Ignored"<<endl;
                continue;
            }
            forwardstack.push(cur);
            cur=backstack.top();
            backstack.pop();
            cout<<cur<<endl;
        }
        if (cmd=="FORWARD")
        {
            if (forwardstack.empty())
            {
                cout<<"Ignored"<<endl;
                continue;
            }
            backstack.push(cur);
            cur=forwardstack.top();
            forwardstack.pop();
            cout<<cur<<endl;
        }
        if (cmd=="VISIT")
        {
            backstack.push(cur);

            cin>>cur;
            while (!forwardstack.empty())  forwardstack.pop();
            cout<<cur<<endl;

        }
    }


    return 0;
}

「真诚赞赏,手留余香」

111qqz的小窝

真诚赞赏,手留余香

使用微信扫描二维码完成支付