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. mysql的Replication机制

    mysql的Replication机制 参考文档:http://www.doc88.com/p-186638485596.html Mysql的 Replication 是一个异步的复制过程. 从上图 ...

  2. Python之路【第五篇续】:面向对象编程二

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABgQAAALaCAIAAABxja8cAAAgAElEQVR4nOzd6X9Tdd74/+uv+f5uzF

  3. MySQL关键字(保留字)列表

    在使用MySQL的时候,一般尽量避免用关键字作为表名,如使用关键字做表名,需要按标准写法给SQL语句加[](或是“)区分字段名和表名. 下面列出MySQL所有关键字,希望给使用MySQL的朋友提供一些 ...

  4. 大数据架构师NoSQL建模技术

    从数据建模的角度对NoSQL家族系统做了比较简单的比较,并简要介绍几种常见建模技术. 1.前言 为了适应大数据应用场景的要求,Hadoop以及NoSQL等与传统企业平台完全不同的新兴架构迅速地崛起.而 ...

  5. html css 网络 页面布局 颜色 参考 拾取器网址

    http://blog.163.com/wujinhongisme@126/blog/static/3613698020095115919389/ ========================== ...

  6. standford工具-parser

    stanford自然语言处理开源了很多工具,很实用也很方便,记录下来,以备后用. 第一篇就从句法分析开始吧(所用的平台都是java+eclipse). <一>操作 1.http://www ...

  7. ML—随机森林·1

    Introduction to Random forest(Simplified) With increase in computational power, we can now choose al ...

  8. Linux 信号量大全

    编号 信号名称 缺省动作 说明 1 SIGHUP 终止 终止控制终端或进程 2 SIGINT 终止 键盘产生的中断(Ctrl-C) 3 SIGQUIT dump 键盘产生的退出 4 SIGILL du ...

  9. python 编码 UnicodeDecodeError

    将一个py脚本从Centos转到win运行,出错如下: UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: il ...

  10. Lua模块测试

    Lua模块 ---------------------------------------------------------- ----------------------- 模块测试module_ ...