题意:
题目已经说的很清楚了..>_<
YY;
啊,真心吐血 啊,第几次忘记清空了。。。。。几次的WA,又浪费时间了...苦逼啊
不过字符串的string一些内容还是学习了
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main()
{
stack<string>s_f;//前进栈
stack<string>s_b;//后退栈
string name,url;
string top;
int N;
cin>>N;
while(N--)
{
while (!s_b.empty ()) s_b.pop ();
while (!s_f.empty ()) s_f.pop ();
s_b.push ("http://www.acm.org/");
while (cin>>name&&name!="QUIT")
{
if(name=="VISIT")
{
while(!s_f.empty ()) s_f.pop ();
cin>>url;
s_b.push (url);
cout<<url<<endl;
}
if(name=="BACK")
{
if(s_b.size() ==1) cout<<"Ignored"<<endl;//注意当前页已经在里面了
else
{
top=s_b.top ();
s_b.pop ();
s_f.push (top);
top=s_b.top ();
cout<<top<<endl;
}
}
if(name=="FORWARD")
{
if(s_f.empty ()) cout<<"Ignored"<<endl;
else
{
top=s_f.top();
s_f.pop ();
s_b.push (top);
cout<<top<<endl;
}
}
}
if(N) cout<<endl;
}
return 0;
}