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 互素的数 ...
随机推荐
- js的DOM对象
1.js的Array对象 ** 创建数组(三种) - var arr1 = [1,2,3]; ...
- yii2-按需加载并管理CSS样式/JS脚本
原文地址:https://segmentfault.com/a/1190000003742452
- gradle 默认属性
Properties(未翻译) Property Description allprojects 包含该项目及其子项目的属性 ant The AntBuilder for this project. ...
- linux下的chm阅读器?
pre和code标签是可以同时使用的, 通常pre放在code的前面. 由于 code, pre中不能使用 换行, 段落, 和 尖括号标签, 所以, 对于尖括号, 要换成 html的 实体符号 < ...
- [译]Bundling and Minification
原文:http://www.asp.net/mvc/overview/performance/bundling-and-minification============================ ...
- 解决英文或数字在HTMl网页中不自动换行。
对于网页设计的新手而言,在接触一段时间的HTML/CSS后,一定会遇到这样的问题:对于已经定义了宽度的容器(如DIV,TD,段落等)如果里面出现了较长的英文或数字,则内容不能自动换行然后会将框架撑出设 ...
- iOS: ARC & MRC下string内存管理策略探究
ARC & MRC下string内存管理策略探究 前两天跟同事争论一个关于NSString执行copy操作以后是否会发生变化,两个人整了半天,最后写代码验证了一下,发现原来NSString操作 ...
- 关于Tchar
因为C++支持两种字符串,即常规的ANSI编码(使用""包裹)和Unicode编码(使用L""包裹),这样对应的就有了两套字符串处理函数,比如:strlen和w ...
- POJ 2486 Apple Tree
好抽象的树形DP......... Apple Tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6411 Accepte ...
- 非阻塞SOCKET套接字connect等待时间的实现
SOCKET cClient; cClient=socket(AF_INET,SOCK_STREAM,0); //设置为非阻塞套接字 int iMode = 1; i ...