北大poj- 1028
Web Navigation
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 33281 | Accepted: 14836 |
Description
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
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
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/
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
Source
#include <stdio.h>
#include <string.h> #define MAX_NUM 100 int main()
{
char input[MAX_NUM];
char now[MAX_NUM] = "http://www.acm.org/";
char stackForward[MAX_NUM][MAX_NUM];
char stackBack[MAX_NUM][MAX_NUM];
int stackF = ;
int stackB = ; memset(stackForward, , MAX_NUM * MAX_NUM * sizeof(char));
memset(stackBack, , MAX_NUM * MAX_NUM * sizeof(char)); while()
{
scanf(" %s",input);
if(strcmp(input, "VISIT") == )
{
stackF = ;
strcpy(stackBack[stackB++], now);
scanf(" %s", now);
}
else if(strcmp(input, "BACK") == )
{
if(stackB == )
{
printf("Ignored\n");
continue;
}
strcpy(stackForward[stackF++], now);
strcpy(now, stackBack[--stackB]);
}
else if(strcmp(input, "FORWARD") == )
{
if(stackF == )
{
printf("Ignored\n");
continue;
}
strcpy(stackBack[stackB++], now);
strcpy(now, stackForward[--stackF]);
}
else if(strcmp(input, "QUIT") == )
{
break;
}
printf("%s\n", now);
} return ;
}
北大poj- 1028的更多相关文章
- 北大POJ题库使用指南
原文地址:北大POJ题库使用指南 北大ACM题分类主流算法: 1.搜索 //回溯 2.DP(动态规划)//记忆化搜索 3.贪心 4.图论 //最短路径.最小生成树.网络流 5.数论 //组合数学(排列 ...
- poj 1028
http://poj.org/problem?id=1028 题意(水):做一个游览器的历史记录. back:后退到上一个页面,当上一个页面没有时,输出ignored. forward:向前一个页面, ...
- 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 ...
随机推荐
- Centos启动Cassandra交互模式失败:No appropriate python interpreter found
在CentOS6.5安装好Cassandra后,启动交互模式: bin/sqlsh 192.168.10.154 时,报错 No appropriate python interpreter foun ...
- SSL/TLS协议运行机制的概述
互联网的通信安全,建立在SSL/TLS协议之上. 本文简要介绍SSL/TLS协议的运行机制.文章的重点是设计思想和运行过程,不涉及具体的实现细节.如果想了解这方面的内容,请参阅RFC文档. 一.作用 ...
- mybatis高级(3)_延迟加载_深度延迟_一级缓存_二级缓存
设置延迟加载需要在mybatis.xml中设置 注: 侵入式延迟加载为真时是延迟加载 侵入式延迟加载为假时是深度延迟加载 <!-- 延迟加载和深度延迟加载 --> <settings ...
- C++11 智能指针
C++ 11标准库引入了几种智能指针 unique_ptr shared_ptr weak_ptr C++内存管理机制是当一个变量或对象从作用域过期的时候就会从内存中将他干掉.但是如果变量只是一个指针 ...
- MEF的学习笔记
为什么要使用MEF 在商业应用软件开发过程中,对于各个软件项目,都需要建立相应的系统框架,为了更好的规范系统的开发,提高生产效率,应该在公司级别制定相应的API标准.这些API标准将站在系统架构层次, ...
- ArcMap Add-in插件开发中解决VS调试时断点不会命中的问题
在VS2010中进行ArcMap Add-in插件开发(ArcEngine10.1,ArcGIS10.1),运行时为.NET4.0,在程序中设置了断点进行调试,但是运行后程序并不会在断点处停止,且原来 ...
- mysql取前几行数据limit用法
转自http://www.cnblogs.com/study100/archive/2013/07/30/3224250.html 在mysql中是没有top关键字的,在mysql中可以用limit来 ...
- android回收AnimationDrawable动画的每一帧的图片资源,而释放内存
回收每一帧的图片,释放内存资源 private void tryRecycleAnimationDrawable(AnimationDrawable animationDrawables) { if ...
- ASP.NET MVC4 请不要将你的Control命名为APIController
今天小猪就遇到了这个坑,虽然小猪知道MVC4已经默认提供了APIController类,这样如果某Control继承自这个APIController的话会使用其自带的REST服务等等,但是之前小猪想我 ...
- Kingsoft Office Writer 2012 8.1.0.3385 - (.wps) Buffer Overflow Exploit (SEH)
#!/usr/bin/python # Exploit Title: Kingsoft Office Writer v2012 8.1.0.3385 .wps Buffer Overflow Expl ...