zoukankan      html  css  js  c++  java
  • POJ 1028 Web Navigation

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

    #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;
    }
  • 相关阅读:
    假期学习总结2-14
    假期学习总结2-13
    假期总结2-12
    假期总结2-11
    读人月神话
    冲刺第五天 11.29 THU
    冲刺第四天 11.28 WED
    冲刺第三天 11.27 TUE
    冲刺第二天 11.26 MON
    冲刺第一天 11.23 FRI
  • 原文地址:https://www.cnblogs.com/111qqz/p/4629356.html
Copyright © 2011-2022 走看看