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. jQuery 根据城市时区,选择对应的即时时间

    我们的CRM系统中,下面是用jQuery 做了个时区小插件 如图: // 时区城市//$(function(){//所有城市和时间静态输出//var cityID = 170; //中国,北京//va ...

  2. Apache日志配置详解(rotatelogs LogFormat)

    logs/error_logCustomLog logs/access_log common--默认为以上部分 修改为如下: ErrorLog "|/usr/sbin/rotatelogs ...

  3. spring之BeanFactoryAware接口

    springBeanFactoryAware (转)要直接在自己的代码中读取spring的bean,我们除了根据常用的set外,也可以通过spring的BeanFactoryAware接口实现,只要实 ...

  4. java.lang.reflect.Constructor

    java.lang.reflect.Constructor 一.Constructor类是什么 Constructor是一个类,位于java.lang.reflect包下. 在Java反射中 Cons ...

  5. 【Junit】JUnit-4.12使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误

    下载了最新的JUnit版本,是4.12,结果尝试使用发现总是报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing这样的错误, 上网查 ...

  6. 微信事业群WXG成立 致力于打造微信大平台

    今天,微信之父张小龙带领微信团队成立微信事业群(WeiXin Group,简称WXG),致力于打造微信大平台,由他们负责微信基础平台.微信开放平台.微信支付拓展.O2O等微信延伸业务的发展,并包括邮箱 ...

  7. hdu.1104.Remainder(mod && ‘%’ 的区别 && 数论(k*m))

    Remainder Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  8. 改造 ThinkPHP,弃用 D() 等魔术函数

    ThinkPHP 是国内比较优秀的 PHP 框架,但有些地方不是很好,比如那些 魔术函数 D(),用它返回的类实例,在各个IDE(如 PhpStorm)下根本识别不了,导致如下问题: 1.不支持 代码 ...

  9. java执行顺序

    本文讨论Java中(静态)变量.(静态)代码块的执行顺序 首先创建3个类: 1.Foo类,用于打印变量 public class Foo { public Foo(String word) { Sys ...

  10. iOS resign code with App Store profile and post to AppStore

    http://stackoverflow.com/questions/17545452/ios-resign-code-with-app-store-profile-and-post-to-appst ...