两个栈
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main()
{
freopen("input.txt","r",stdin);
freopen("output3.txt","w",stdout);
stack<string>sb,sf;
string in;
string out;
sb.push("http://www.acm.org/");
while(cin>>in){
if(in=="VISIT"){
cin>>out;
sb.push(out);
cout<<out<<endl;
while(!sf.empty()){
sf.pop();
}
}
if(in=="BACK"){
if(sb.size()>1){
sf.push(sb.top());
sb.pop();
cout<<sb.top()<<endl;
}
else{
cout<<"Ignored"<<endl;
}
}
if(in=="FORWARD"){
if(!sf.empty()){
sb.push(sf.top());
cout<<sf.top()<<endl;
sf.pop();
}
else{
cout<<"Ignored"<<endl;
}
}
if(in=="QUIT"){
break;
}
}
return 0;
}