Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题很侮辱智商的地方是吧做题的方法告诉我们了……附1a代码

Posted by whus2010301500230 at 2012-03-24 22:09:15 on Problem 1028
真的很水,告诉我们要两个stack,怎么入栈怎么出栈也都告诉我们了……

/*
poj: 1028 Web Navigation
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>

using namespace std;

string str;
stack<string> backward;
stack<string> forward;
string current = "http://www.acm.org/";

int main()
{
    //freopen("data.in", "rb", stdin);
    while(cin >> str) {
        if(str == "QUIT")
            break;
        else if(str == "VISIT") {
            backward.push(current);
            cin >> current;
            cout << current << endl;
            while(!forward.empty())
                forward.pop();
        }
        else if(str == "BACK") {
            if(!backward.empty()) {
                forward.push(current);
                current = backward.top();
                backward.pop();
                cout << current << endl;
            }
            else
                cout << "Ignored" << endl;
        }
        else if(str == "FORWARD") {
            if(!forward.empty()) {
                backward.push(current);
                current = forward.top();
                forward.pop();
                cout << current << endl;
            }
            else
                cout << "Ignored" << endl;
        }
    }
    
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator