zoukankan      html  css  js  c++  java
  • 计蒜客--网页跳转问题

     

    AC代码:

    #include <iostream>
    #include <stack>
    #include <string>
    using namespace std;
    int main() {
        ios::sync_with_stdio(false);   //避免超时
        stack<string> s1;
        stack<string> s2;
        int n;
        cin >> n;
        while (n--) {
            string str1, str2;
            cin >> str1;
            if (str1 == "VISIT") {
                cin >> str2;
                while (!s2.empty()) {//清空s2
                    s2.pop();
                }
                s1.push(str2);
                cout << s1.top() << endl;
            }
            else if (str1 == "BACK") {
                if (s1.empty()) {
                    cout << "Ignore" << endl;
                }
                else {
                    s2.push(s1.top());
                    s1.pop();
                    if (!s1.empty()) {
                        cout << s1.top() << endl;
                    }
                    else {
                        cout << "Ignore" << endl;
                        s1.push(s2.top());
                        s2.pop();
                    }
                }
            }
            else {
                if (s2.empty()) {
                    cout << "Ignore" << endl;
                }
                else {
                    if (!s2.empty()) {
                        cout << s2.top() << endl;
                        s1.push(s2.top());
                        s2.pop();
                    }
                    else {
                        cout << "Ignore" << endl;
                    }
                }
    
            }
        }
    }
  • 相关阅读:
    typeof用法
    图片上传显示图片
    用Express 创建项目
    Express中使用session
    生成一个node项目
    async同步异步
    async异步流程控制
    nodejs并行无关联
    nodejs串行有关联
    nodejs串行无关联
  • 原文地址:https://www.cnblogs.com/pythonbigdata/p/8748125.html
Copyright © 2011-2022 走看看