| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这题很侮辱智商的地方是吧做题的方法告诉我们了……附1a代码真的很水,告诉我们要两个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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator