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 ...
随机推荐
- Django 连接 Mysql (8.0.16) 失败
首先,确认数据库配置正确无误: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # or use: mysql.con ...
- SSM-Maven配置
全配置 新建项目 新建文件夹 - src - main - java - resources - webapp - WEB-INF - index.jsp - pom.xml <?xml ver ...
- [Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和)
[Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和) E. Permuta ...
- spring事务代码实践
事务一般是指数据库事务,是指作为一个程序执行单元执行的一系列操作,要么完全执行,要么完全不执行.事务就是判断以结果为导向的标准. 一.spring的特性(ACID) (1).原子性(atomicity ...
- Linux学习计划(一)
一.用途:网络服务器 二.优点: 1.开源免费 2.良好的可移植性 3.安全性 三.安装Linux 工具:VMware workstation .centOS7 安装步骤 图片加载中... 说明: Ⅰ ...
- Linux-10Year
主流Linux发行版近10年排行曲线 10个主流的发行版概述(distrowatch挑选) 搜索特定的发行 选择建议 初级用户选择:开箱即用 中级用户组装:适合你自己的系统 高 ...
- tan?
痰是一种急.慢性气管--支气管炎,咳.痰.喘.炎是下呼吸道感染的常见主征.下呼吸道感染有急性和慢性之分.急性感染主要的是急性气管--支气管炎,是呼吸系统最常见的一种疾病,多由感染.物理化学刺激或过敏引 ...
- SQL中的Where,Group By,Order By和Having
说到SQL语句,大家最开始想到的就是他的查询语句: select * from tableName: 这是最简单的一种查询方式,不带有任何的条件. 当然在我们的实际应用中,这条语句也是很常用到的,当然 ...
- 什么是IPFS?IPFS与区块链有什么关系
1.什么是IPFS? IPFS是Inter Planetary File System(星际文件系统)的缩写,是一个典型的点对点分布式文件系统, 旨在用同一个文件系统连接所有的计算设备.这时候有些小伙 ...
- 配置 git公钥报错:unknown key type -rsa
配置 git公钥的时候出现:ssh-keygen unknown key type -rsa 一个解决办法是去本地寻找.ssh文件,参考路径(C:\Users\Administrator.ssh),把 ...