北大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 ...
随机推荐
- Appium 服务关键字
Appium 服务关键字 关键字 描述 实例 automationName 你想使用的自动化测试引擎 Appium (默认) 或 Selendroid platformName 你要测试的手机操作系统 ...
- js中对象 类 实例的区别 数据类型 创建对象
类是对象的具体细分,实例是类中的一个具体事物. 基本数据类型和 引用数据类型 基本数据类型:numble string undefined null 引用数据类型:对象和函数 对象数据类型又细分为:对 ...
- css3动画参数解释
@keyframes规定动画.animation 所有动画属性的简写属性,除了 animation-play-state 属性. ----------------------------------- ...
- css3实现颜色渐变以及兼容性处理
有时我们会看到网站上的一些图片是渐变色的,这些图片有的是ui设计出来的,有的则是直接通过css3制作出来的.下面就讲一下css3实现渐变色的方法,以及在各个浏览器上的兼容性. CSS3 Gradien ...
- oralce 密码长度
Oracle 11G的新特性所致, Oracle 11G创建用户时缺省密码过期限制是180天, 如果超过180天用户密码未做修改则该用户无法登录. Oracle提示错误消息ORA-28001: the ...
- 由于客户端检测到一个协议错误 代码0x1104
重新连接N次都还是这个错误提示,最后再重起电脑,还是没用.研究了一下错误终于解决了. 首先检查远程连接端口对不对?Windows远程默认的连接端口是3389,一般大家连接时直接输入IP或域名就可以连接 ...
- jquery笔记之属性选择器 查找以某种条件开头的页面元素
jquery笔记之属性选择器 查找以某种条件开头的页面元素 转载:http://www.blogbus.com/amyqiong-logs/78340326.html $("div[id]& ...
- asp.net发邮件功能
protected void SendMail() { try { string CreaterName = ""; string examiner = ""; ...
- ASCII编码对照表
Bin(二进制) Oct(八进制) Dec(十进制) Hex(十六进制) 缩写/字符 解释 0000 0000 0 0 00 NUL(null) 空字符 0000 0001 1 1 01 SOH(st ...
- nodeType的意思
nodeType是用来获得当前节点对象的类型.nodeType 属性可返回节点的类型.元素element 1 属性attr 2 文本text 3 注释comments 8 ...