POJ 1028(简单的模拟浏览器)

来源:互联网 发布:多益网络的手游 编辑:程序博客网 时间:2024/05/24 02:54

#include<iostream>#include<string>#include<cstring>#include<stack>using namespace std;stack <string> sta,temp;char str[8]="VISTT";int main(){sta.push("http://www.acm.org/");string url;while(1){scanf("%s",str);switch(str[0]){case 'Q':return 0;case 'V':while(temp.size()) temp.pop();cin>>url;sta.push(url);cout<<sta.top()<<endl;break;case 'B':if(sta.size()>1){temp.push(sta.top());sta.pop();cout<<sta.top()<<endl;}elseprintf("Ignored\n");break;case 'F':if(temp.size()>0){sta.push(temp.top());temp.pop();cout<<sta.top()<<endl;}elseprintf("Ignored\n");break;default:break;}}return 0;}

这个题:要注意的地方,也就是逻辑错误:


当VISIT时,你的FORWARD的栈要清空,因为要重新访问了一个网页。


原创粉丝点击