poj 1028 Web Navigation
#include <iostream> //水题
#include <string>
#include<stack>
using namespace std;
int main()
{
stack<string> back,forword;
string str,current="http://www.acm.org/";
while(cin>>str&&str!="QUIT")
{
if(str=="VISIT")
{
back.push(current);
cin>>current;
while(!forword.empty())
forword.pop();
cout<<current<<endl;
}
else if(str=="BACK")
{
if(!back.empty())
{
forword.push(current);
current=back.top();back.pop();
cout<<current<<endl;
}
else
cout<<"Ignored\n";
}
else if(str=="FORWARD")
{
if(!forword.empty())
{
back.push(current);
current=forword.top();forword.pop();
cout<<current<<endl;
}
else
cout<<"Ignored\n";
}
}
return 0;
}