博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 1028 Web Navigation
阅读量:6845 次
发布时间:2019-06-26

本文共 2428 字,大约阅读时间需要 8 分钟。

Description

Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you 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

Input is a sequence of commands. The command keywords BACK, FORWARD, VISIT, and QUIT are all in uppercase. URLs have no whitespace and have at most 70 characters. You may assume that no problem instance requires more than 100 elements in each stack at any time. The end of input is indicated by the QUIT command.

Output

For each command other than QUIT, print the URL of the current page after the command is executed if the command is not ignored. Otherwise, print "Ignored". The output for each command should be printed on its own line. No output is produced for the QUIT command.

Sample Input

VISIT http://acm.ashland.edu/VISIT http://acm.baylor.edu/acmicpc/BACKBACKBACKFORWARDVISIT http://www.ibm.com/BACKBACKFORWARDFORWARDFORWARDQUIT

Sample Output

http://acm.ashland.edu/http://acm.baylor.edu/acmicpc/http://acm.ashland.edu/http://www.acm.org/Ignoredhttp://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 
#include
#include
#include
using namespace std;int main(){
int t=0,c[10000]; memset(c,0,sizeof(c)); string a[10000]; a[0]="http://www.acm.org/";c[0]=1;string b;while(cin>>b&&b[0]!='Q'){
if(b[0]=='V'){
t++; cin>>a[t];cout<
<

转载于:https://www.cnblogs.com/lengxia/p/4387795.html

你可能感兴趣的文章
数据交换=>Windows_Mobile+WCF+Exchange2007 - part1
查看>>
下载ORACLE中BLOB内容到客户端
查看>>
matlab练习程序(图像放大/缩小,双立方插值)
查看>>
mysql命令
查看>>
第一章面向对象涉及原则
查看>>
SQL Server索引调优系列
查看>>
SQL 2000中的触发器使用
查看>>
CKEditor与CKFinder的配置(ASP.NET环境)
查看>>
linux运行级别
查看>>
High Availability PostgreSQL HOWTO
查看>>
C#继承机制
查看>>
Silverlight开发工具汇总
查看>>
简单设计实现基于Forms认证的注册登录等用户基础服务
查看>>
MySQL Query Cache 小结
查看>>
MusicXML 3.0 (6) - 符杠分组
查看>>
分享一个比lightbox配置更方便的jQuery web2.0图片显示插件:Topup
查看>>
Linux IPTables: Incoming and Outgoing Rule Examples (SSH and HTTP)
查看>>
C以二进制读、写、文本
查看>>
SYS_Oracle Erp打印机设定(案例)
查看>>
VBS基础篇 - 循环语句(3) - For...Next
查看>>