码迷,mamicode.com
首页 > Web开发 > 详细

计蒜客--网页跳转问题

时间:2018-04-09 00:17:26      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:com   .com   class   代码   else   style   图片   str1   png   

技术分享图片

 

技术分享图片

技术分享图片

 技术分享图片

技术分享图片

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;
                }
            }

        }
    }
}

 

计蒜客--网页跳转问题

标签:com   .com   class   代码   else   style   图片   str1   png   

原文地址:https://www.cnblogs.com/pythonbigdata/p/8748125.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!