zoukankan      html  css  js  c++  java
  • 题目:Web浏览

    题目描述

    实现浏览器的页面前后访问机制。有四种命令:
    1、BACK;
    2、FORWARD;
    3、VISIT:访问新的页面;
    4、QUIT:退出浏览器。
    请参考实际的浏览器按钮的功能。
    假设浏览器打开时,显示的页面是:http://www.acm.org/

    输入格式

    一系列命令:以BACK、FORWARD、VISIT或QUIT开头。如果是VISIT,后面要跟URL,长度不超过70,且不含空格。最后总是以QUIT结尾。

    题解:

    该题是看了别人的题解而成。要领会。。。。

    代码实现:

    View Code
     1 #include<iostream>
    2 #include<cstring>
    3 using namespace std;
    4
    5 string back[100],forw[100],now;
    6 int top1=-1,top2=-1;
    7
    8 int main()
    9 {
    10 string a;
    11 now="http://www.acm.org/";
    12 cin>>a;
    13 while(a!="QUIT")
    14 {
    15 if(a=="VISIT")
    16 {
    17 top2=-1;
    18 top1++;
    19 back[top1]=now;
    20 cin>>now;
    21 cout<<now<<endl;
    22 }
    23 if(a=="FORWARD")
    24 {
    25 if(top2>-1)
    26 {
    27 top1++;
    28 back[top1]=now;
    29 now=forw[top2];
    30 top2--;
    31 cout<<now<<endl;
    32 }
    33 else cout<<"Ignored"<<endl;
    34 }
    35 if(a=="BACK")
    36 {
    37 if(top1>-1)
    38 {
    39 top2++;
    40 forw[top2]=now;
    41 cout<<back[top1]<<endl;
    42 now=back[top1];
    43 top1--;
    44 }
    45 else cout<<"Ignored"<<endl;
    46 }
    47 cin>>a;
    48 }
    49 return 0;
    50 }
  • 相关阅读:
    PowerDesigner中Table视图同时显示Code和Name
    sql语句 生成数据库表
    业务流程图
    物理模型图-数据库图
    观察者模式
    UML的九种图
    路由器工作原理
    web项目中处理捕获异常统一处理
    java中volatile、synchronized
    linux 安装软件的几种方法
  • 原文地址:https://www.cnblogs.com/noip/p/2330732.html
Copyright © 2011-2022 走看看