北大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 ...
随机推荐
- Linux乱码问题解决方案
欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...
- VNC SERVER配置
vnc的配置网上有很多 普通用户的配置没有怎么写 根据下面这个说法 https://www.digitalocean.com/community/tutorials/how-to-install-an ...
- 20155229-付钰涵-分析自我技能延展到c语言学习状况
我的小技能 我记得幼儿园时表演的舞蹈,也记得从水彩到素描的学习,还记得小学和初中获得的钢琴省级奖项. 舞蹈止于一年级,绘画止于三年级,钢琴从学前班到高一那十年的时间里有过断续. 03年-04年的那个冬 ...
- CentOS 7 配置静态IP
1.查看MAC地址 2.修改/etc/sysconfig/network-scripts/ifcfg-[第一步中红框内的文字] 3.添加和修改内容如下: 4.修改/etc/resolv.conf 5. ...
- django orm总结[转载]
django orm总结[转载] 转载地址: http://www.cnblogs.com/linjiqin/archive/2014/07/01/3817954.html 目录1.1.1 生成查询1 ...
- BZOJ2329 [HNOI2011]括号修复
把左括号看做$1$,右括号看做$-1$,于是查询操作等于查询一个区间左边右边最大(最小)子段和 支持区间翻转,反转,覆盖操作...注意如果有覆盖操作,之前的操作全部作废了...于是在下传标记的时候要最 ...
- Java8之——简洁优雅的Lambda表达式
Java8发布之后,Lambda表达式,Stream等等之类的字眼边慢慢出现在我们字眼.就像是Java7出现了之后,大家看到了“钻石语法”,看到了try-with-resource等等.面对这些新东西 ...
- 微信开发订阅号(ASP.NET MVC4+jquery mobile+AppHarbor发布)
首先应该去微信公众平台注册一个账号,因为我是用的个人,所以只能注册订阅号,然后需要提供身份证照片,这些大家慢慢折腾.然后在微信管理面板中选择高级功能,进入开发者模式. 在服务器配置中需要提供最重要的u ...
- hdoj 1385Minimum Transport Cost
卧槽....最近刷的cf上有最短路,本来想拿这题复习一下.... 题意就是在输出最短路的情况下,经过每个节点会增加税收,另外要字典序输出,注意a到b和b到a的权值不同 然后就是处理字典序的问题,当松弛 ...
- The requested resource is not available...
运行tomcat 提示如下错误: The requested resource () is not available的解决方案 出现这个问题,接口肯定是没问题了.问题可能有两个: 1.文件设置无法访 ...