http://poj.org/problem?id=1028

题意(水):做一个游览器的历史记录。

back:后退到上一个页面,当上一个页面没有时,输出ignored.

forward:向前一个页面,但此页面为最前的页面时,输出ignored.

vista:游览所指定的页面。

quit:退出。

解题思路:题目是说用栈,但不用栈也是可以的。就用纯数组来模拟就栈。

我用的是string类型,这个类型有个好处,就是比较不用strcmp函数,还有输入方便,直接cin就行。但其实本质就是char[];

 #include <stdio.h>
#include <string.h>
#include <string>
#include <iostream> using namespace std; string str[],str1[]; //记得数组不能开太小,开太小就会RE。 int main()
{
int n=,mark=,now=;
str1[]="http://www.acm.org/"; //题目说最原始的页面就是这个acm的。
while(cin>>str[n]&&str[n]!="QUIT"){
if(str[n]=="VISIT"){
mark++;
now++;
if(mark>now) mark=now; //页面的覆盖。
cin>>str1[mark];
}
if(str[n]=="VISIT") {
cout<<str1[mark]<<endl;
}
if(str[n]=="BACK") {
if(now==) cout<<"Ignored"<<endl;
else cout<<str1[--now]<<endl;
}
if(str[n]=="FORWARD"){
if(now==mark) cout<<"Ignored"<<endl;
else cout<<str1[++now]<<endl;
}
n++;
}
return ;
}

poj 1028的更多相关文章

  1. poj 1028 Web Navigation(模拟)

    题目链接:http://poj.org/problem? id=1028 Description Standard web browsers contain features to move back ...

  2. poj 1028 Web Navigation

    Web Navigation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31088   Accepted: 13933 ...

  3. poj 1028 Web Navigation 【模拟题】

    题目地址:http://poj.org/problem?id=1028 测试样例: Sample Input VISIT http://acm.ashland.edu/ VISIT http://ac ...

  4. POJ 1028解答

    #include <iostream>#include <cstdio>#include <cmath>#include <stack>#include ...

  5. POJ 1028题目描述

    Description Standard web browsers contain features to move backward and forward among the pages rece ...

  6. POJ 1028 Web Navigation 题解

    考查代码能力的题目.也能够说是算法水题,呵呵. 推荐新手练习代码能力. 要添加难度就使用纯C实现一下stack,那么就有点难度了,能够使用数组模拟环形栈.做多了,我就直接使用STL了. #includ ...

  7. 【stack】模拟网页浏览 poj 1028

    #include<stdio.h> #include<string.h> int main() { ][]; ]; int i,depth; strcpy(s[]," ...

  8. POJ 1028:Web Navigation

    Web Navigation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 30828   Accepted: 13821 ...

  9. FJUTOJ-周赛2016-12-16

    注:fjutoj基本每周都有一次周赛,欢迎大家都来参加! 网址:http://59.77.139.92/index.jsp A题:来源 POJ 2773 题意:给两个数m和k,问第k 个和m 互素的数 ...

随机推荐

  1. Think in Java(Java编程思想)-第2章 一切都是对象

    1. String s = "asdf"//创建一个String引用,并初始化. String s = new String("asdf")//创建一个新对象, ...

  2. 脱离 Spring 实现复杂嵌套事务,之一(必要的概念)

    事务传播行为种类 Spring在TransactionDefinition接口中规定了7种类型的事务传播行为, 它们规定了事务方法和事务方法发生嵌套调用时事务如何进行传播: 表1事务传播行为类型 事务 ...

  3. 如何获取客户端MAC地址(三个方法)

    方法一: 调用Windows的DOS命令,从输出结果中读取MAC地址: public static String getMACAddress() { String address = "&q ...

  4. [译]Create a Web API in MVC 6

    原文: http://www.asp.net/vnext/overview/aspnet-vnext/create-a-web-api-with-mvc-6 ASP.NET 5.0的一个目标是合并MV ...

  5. Sturts2的action不执行任何方法的原因

    今天用<s:url action="xxx">调用action的时候出现了一个“异常”, action里的任何方法都没有执行,直接返回success,而且没有任何报错. ...

  6. Hadoop 面试题redis

    Hadoop 面试题之十 548.redis有什么特别之处,为什么用redis,用hbase 不行么? 答:redis 是基于内存的数据库,速度快 551.redis用什么版本? 3.0以上才支持集群 ...

  7. php 正则表达式的使用

    要点:php正则表达式要用双引号,且要用“/ /”斜线做开始结束. 1.preg_match . preg_match_all 两者的区别:第一次匹配成功后就会停止匹配,如果要实现全部结果的匹配,即搜 ...

  8. codeblocks+Mingw 下配置开源c++单元测试工具 google test

    google test 是google的c++开源单元测试工具,chrome的开发团队就是使用它. Code::Blocks 12.11(MinGW 4.7.1) (Windows版)Google T ...

  9. PHP Socket实现websocket(三)Stream函数

    除了socket函数也可以使用stream函数来实现服务器与客户端. 参考PHP 的Stream实现服务器客户端模型: http://php.net/manual/en/book.stream.php ...

  10. nginx反向代理、动静分离

    环境:根据http://www.cnblogs.com/zzzhfo/p/6032095.html配置 方法一:根据目录实现动静分离 在web01创建image并上传一张图片作为静态页面 [root@ ...