poj 1028
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的更多相关文章
- poj 1028 Web Navigation(模拟)
题目链接:http://poj.org/problem? id=1028 Description Standard web browsers contain features to move back ...
- poj 1028 Web Navigation
Web Navigation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 31088 Accepted: 13933 ...
- poj 1028 Web Navigation 【模拟题】
题目地址:http://poj.org/problem?id=1028 测试样例: Sample Input VISIT http://acm.ashland.edu/ VISIT http://ac ...
- POJ 1028解答
#include <iostream>#include <cstdio>#include <cmath>#include <stack>#include ...
- POJ 1028题目描述
Description Standard web browsers contain features to move backward and forward among the pages rece ...
- POJ 1028 Web Navigation 题解
考查代码能力的题目.也能够说是算法水题,呵呵. 推荐新手练习代码能力. 要添加难度就使用纯C实现一下stack,那么就有点难度了,能够使用数组模拟环形栈.做多了,我就直接使用STL了. #includ ...
- 【stack】模拟网页浏览 poj 1028
#include<stdio.h> #include<string.h> int main() { ][]; ]; int i,depth; strcpy(s[]," ...
- POJ 1028:Web Navigation
Web Navigation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 30828 Accepted: 13821 ...
- FJUTOJ-周赛2016-12-16
注:fjutoj基本每周都有一次周赛,欢迎大家都来参加! 网址:http://59.77.139.92/index.jsp A题:来源 POJ 2773 题意:给两个数m和k,问第k 个和m 互素的数 ...
随机推荐
- C++基础入门
#include "iostream" using namespace std; class A{ public: A(int x1){ x = x1; } ...
- HttpUtility.UrlEncode 和 HttpUtility.Encode 一个大深坑
进行了 Encode 之后 在解码(UrlEncode )之后 + 号莫名的变成了空格, 需要执行一个replace 操作
- php:Header
转自鸟哥的博客: http://www.laruence.com/2007/12/16/308.html PHP header()the function declaration: void head ...
- FZU2169 shadow题解
http://acm.fzu.edu.cn/problem.php?pid=2169 Problem Description YL 是shadow国的国王,shadow国有N个城市.为了节省开支,sh ...
- 淘宝首页源码藏美女彩蛋(上)(UED新作2013egg)
今日,偶尔翻看淘宝源码,发现竟有美女形状源码.如下图: 此段代码在console中运行,结果更为惊叹. 亲手尝试的读者已经看到了代码运行的结果.taobao.com的console打印出了UED的招聘 ...
- R笔记 map_leaflet googlevis
packages : map leaflet library(leaflet) library(maps) mapStates = map("state", fill = TRUE ...
- Java并发包源码学习之线程池(一)ThreadPoolExecutor源码分析
Java中使用线程池技术一般都是使用Executors这个工厂类,它提供了非常简单方法来创建各种类型的线程池: public static ExecutorService newFixedThread ...
- POJ 2155 Matrix
二维树状数组.... Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissio ...
- Ubuntu 14 安装Java(JRE、JDK)
JRE vs OpenJDK vs Oracle JDK JRE(Java Runtime Environment),它是你运行一个基于Java语言应用程序的所正常需要的环境.如果你不是一个程序员的话 ...
- 使用xp光盘修复系统的方法步骤
对于使用Windows XP系统的朋友来说,当系统出现崩溃或者系统使用时出现一些莫名其妙的错误时,你采用什么方法解决呢?一般都是采用重装系统或者使用Ghost恢复等. 但是使用这些方法各有缺陷,比如重 ...