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;
                    }
                }
    
            }
        }
    }
  • 相关阅读:
    java 构建一个简单的菜单
    java JSplitPane
    java 使用ActionListener监控
    java 显示单选按钮
    工作 激情
    明天会更好
    记录
    现在
    嘿嘿
    书籍 知识
  • 原文地址:https://www.cnblogs.com/pythonbigdata/p/8748125.html
Copyright © 2011-2022 走看看