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

  

posted on 2011-07-22 16:55  sysu_mjc  阅读(144)  评论(0编辑  收藏  举报

导航