Web浏览

Web浏览
Time Limit: 1000ms Memory Limit: 65536KB
描述
Descript.

实现浏览器的页面前后访问机制。有四种命令:
1、BACK;
2、FORWARD;
3、VISIT:访问新的页面;
4、QUIT:退出浏览器。
请参考实际的浏览器按钮的功能。
假设浏览器打开时,显示的页面是:http://www.acm.org/
输入
Input
一系列命令:以BACK、FORWARD、VISIT或QUIT开头。如果是VISIT,后面要跟URL,长度不超过70,且不含空格。最后总是以QUIT结尾。
输出
Output
对于每一个命令(除了QUIT),输出浏览页面的URL,如果命令被忽略,输出:Ignored。
样例
Sample
输入数据
VISIT http://acm.ashland.edu/
VISIT http://asm.baylor.edu/acmipc/
BACK
BACK
BACK
FORWARD
VISIT http://www.ibm.com/
BACK
BACK
FORWARD
FORWARD
FORWARD
QUIT
输出数据
http://acm.ashland.edu/
http://asm.baylor.edu/acmipc/
http://acm.ashland.edu/
http://www.acm.org/
Ignored
http://acm.ashland.edu/
http://www.ibm.com/
http://acm.ashland.edu/
http://www.acm.org/
http://acm.ashland.edu/
http://www.ibm.com/
Ignored

#include<iostream>
#include<cstring>
#include<stdio.h>
#include<string>
#include<stdlib.h>
using namespace std;

string Back[110],F[110],now;
int flag1=-1,flag2=-1;

int main()
{
    string a;
    now="http://www.acm.org/";
    cin>>a;
    while(a!="QUIT")
    {
        if(a=="VISIT") 
        {
            flag2=-1;
            flag1++;
            Back[flag1]=now;
            cin>>now;
            cout<<now<<endl;
        }  
        if(a=="FORWARD") 
        {
            if(flag2>-1)
            {
                flag1++;
                Back[ flag1]=now;
                now=F[flag2];
                flag2--;
                cout<<now<<endl;
            }
            else cout<<"Ignored"<<endl;           
        }
        if(a=="BACK")
        {
            if(flag1>-1)
            {
                flag2++;
                F[flag2]=now;
                cout<<Back[flag1]<<endl;
                now=Back[flag1];
                flag1--;
            } 
            else cout<<"Ignored"<<endl;      
        }
        cin>>a;                          
    }
    system("pause");
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值