POJ 1028:Web Navigation
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 30828 | Accepted: 13821 |
Description
are asked to implement this.
The following commands need to be supported:
BACK: Push the current page on the top of the forward stack. Pop the page from the top of the backward stack, making it the new current page. If the backward stack is empty, the command is ignored.
FORWARD: Push the current page on the top of the backward stack. Pop the page from the top of the forward stack, making it the new current page. If the forward stack is empty, the command is ignored.
VISIT : Push the current page on the top of the backward stack, and make the URL specified the new current page. The forward stack is emptied.
QUIT: Quit the browser.
Assume that the browser initially loads the web page at the URL http://www.acm.org/
Input
The end of input is indicated by the QUIT command.
Output
Sample Input
VISIT http://acm.ashland.edu/
VISIT http://acm.baylor.edu/acmicpc/
BACK
BACK
BACK
FORWARD
VISIT http://www.ibm.com/
BACK
BACK
FORWARD
FORWARD
FORWARD
QUIT
Sample Output
http://acm.ashland.edu/
http://acm.baylor.edu/acmicpc/
http://acm.ashland.edu/
http://www.acm.org/
Ignored
http://acm.ashland.edu/
http://www.ibm.com/
http://acm.ashland.edu/
http://www.acm.org/
http://acm.ashland.edu/
http://www.ibm.com/
Ignored
水题,题意就是模拟访问网页,看当前网页到了哪里。
代码:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std; map <int,string> web; int main()
{
//freopen("input.txt","r",stdin);
//freopen("out.txt","w",stdout); string operate;
string website; int cur=1,zong=1;
web[1]="http://www.acm.org/"; while(cin>>operate)
{
if(operate=="QUIT")
break;
if(operate=="VISIT")
{
cin>>website;
web[++cur]=website;
zong=cur;
cout<<website<<endl;
}
if(operate=="BACK")
{
if(cur==1)
{
cout<<"Ignored"<<endl;
}
else
{
cur--;
cout<<web[cur]<<endl;
}
}
if(operate=="FORWARD")
{
if(cur==zong)
{
cout<<"Ignored"<<endl;
}
else
{
cur++;
cout<<web[cur]<<endl;
}
}
} //system("pause");
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
POJ 1028:Web Navigation的更多相关文章
- poj 1028 Web Navigation
Web Navigation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 31088 Accepted: 13933 ...
- POJ1028 Web Navigation
题目来源:http://poj.org/problem?id=1028 题目大意: 模拟实现一个浏览器的“前进”和“回退”功能.由一个forward stack和一个backward stack实现. ...
- 知名网站内部资料:WEB页面内容优化管理与性能技巧
回想一下,以前我们不得不花费大量时间去优化页面内容(图片.CSS等等),如今用户有更快速的互联网链接,我们似乎能够使用更大的图像或更大的闪 存文件,里面包含的有视频或者图片.然而,随着移动开发的兴起, ...
- Senparc.Weixin.MP SDK 微信公众平台开发教程(十八):Web代理功能
在Senparc.Weixin.dll v4.5.7版本开始,我们提供了Web代理功能,以方便在受限制的局域网内的应用可以顺利调用接口. 有关的修改都在Senparc.Weixin/Utilities ...
- C#进阶系列——DDD领域驱动设计初探(七):Web层的搭建
前言:好久没更新博客了,每天被该死的业务缠身,今天正好一个模块完成了,继续来完善我们的代码.之前的六篇完成了领域层.应用层.以及基础结构层的部分代码,这篇打算搭建下UI层的代码. DDD领域驱动设计初 ...
- HTML5:web socket 和 web worker
a:hover { cursor: pointer } 做练习遇到了一个选择题,是关于web worker的,问web worker会不会影响页面性能?补习功课之后,答案是不会影响. 查阅了相关资料学 ...
- 案例研究:Web应用间歇性SqlException
最近有客户找到我,说他们生产环境的事件日志中有下面的报错.要我帮忙找找原因. Event Type: Warning Event Source: ASP.NET 2.0.50727.0 Event C ...
- 徐汉彬:Web系统大规模并发——电商秒杀与抢购(转)
[导读]徐汉彬曾在阿里巴巴和腾讯从事4年多的技术研发工作,负责过日请求量过亿的Web系统升级与重构,目前在小满科技创业,从事SaaS服务技术建设. 电商的秒杀和抢购,对我们来说,都不是一个陌生的东西. ...
- 解决Eclipse里的Maven工程pom.xml文件报:web.xml is missing and <failOnMissingWebXml> is set to true错误
打开eclipse准备进行开发时,发现项目上有个红星号,查看错误后发现报了一个:"web.xml is missing and <failOnMissingWebXml> is ...
随机推荐
- JS 自动返回每个月的天数
);//M代表月份,可以自己手动设置或者选择 date.setDate() var num = date.getDate(); console.log(num) //输出每个月的天数 var time ...
- MongoDB in 数量限制
1.查询语句本身其实是一个document, 最大为16MB(3.4,4.0 的限制,官方文档)2.查询语句本身,也就是{ '' : { '$in' : [] }}, 大小为 22字节3.每增加一个字 ...
- jenkins 2.204.2 安装, 使用国内源安装, 并且跳过插件界面, 更新成国内插件源.
需要java环境支持,自行百度. jenkins 安装源在国外, 下载会比较慢, 尤其在linux下, 使用yum或者apt install jenkins方式安装时,经常会下载失败. 由于yum或者 ...
- Maven项目- get请求的乱码问题,使用tamcat7出现乱码的解决方法
get请求的乱码问题: 解决方法: 手动处理编码
- python内置函数三
ord() 函数 和 chr() 相反 chr() 是将数字转换成assci码 ord() 是将字符串转换成assci码 显示 pow() 函数 pow(x,y,z) 表示x**y ...
- HTML设置表格
1. 设置表格内容对齐方式 在HTML中通常通过align设置对齐方式,文字是: text-align ,表格是:align 如果将align属性设置给<table>标签,只能改变< ...
- NPM概述及使用简介
什么是 NPM npm之于Node,就像pip之于Python,gem之于Ruby,composer之于PHP. npm是Node官方提供的包管理工具,他已经成了Node包的标准发布平台,用于Node ...
- ReadAsm2
首先查看题目 下载文档之后用虚拟机打开(我用的是Kali Linux) 推测应该是对这个func函数反汇编结果应该就出来了 用c写一下算出结果 #include<bits/stdc++.h> ...
- 页面的html调试
点击页面按下键盘的F12,或者鼠标右键选择检查(N) 会弹出一个窗口,这个窗口就是调试窗口 如上图所示,第一个图标是标签元素选择器,点击使用后,在页面上移动,会在Elements的区域找到你鼠标选中的 ...
- JS: 图片轮播模板——左右移动,点击编码移动,自动轮播
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title> ...