Web(二维字符数组的应用)(poj)
来源:互联网 发布:带着淘宝去古代txt 编辑:程序博客网 时间:2024/05/19 06:35
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 Output Sample Input Sample Output
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.
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.
VISIT http://acm.ashland.edu/VISIT http://acm.baylor.edu/acmicpc/BACKBACKBACKFORWARDVISIT http://www.ibm.com/BACKBACKFORWARDFORWARDFORWARDQUIT
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<stdio.h>
#include<string.h>
int main()
{
char page[1000][1000];
char caozuo[10];
int top,dangqian,temp;
#include<string.h>
int main()
{
char page[1000][1000];
char caozuo[10];
int top,dangqian,temp;
strcpy(page[1],"http://www.acm.org/ ");
top=1;
temp=1;
top=1;
temp=1;
while(1)
{
scanf("%s",caozuo);
{
scanf("%s",caozuo);
if(strcmp(caozuo,"QUIT")==0)
return 0;
return 0;
if(strcmp(caozuo,"VISIT")==0)
{
top=temp;
top++;
temp++;
scanf("%s",page[top]);
printf("%s\n",page[top]);
}
{
top=temp;
top++;
temp++;
scanf("%s",page[top]);
printf("%s\n",page[top]);
}
if(strcmp(caozuo,"BACK")==0)
{
if(temp-1<1)
printf("Ignored\n");
else
{
printf("%s\n",page[temp-1]);
temp=temp-1;
}
}
{
if(temp-1<1)
printf("Ignored\n");
else
{
printf("%s\n",page[temp-1]);
temp=temp-1;
}
}
if(strcmp(caozuo,"FORWARD")==0)
{
if(temp+1>top)
printf("Ignored\n");
{
if(temp+1>top)
printf("Ignored\n");
else
{
printf("%s\n",page[temp+1]);
temp=temp+1;
}
}
}
return 0;
}
{
printf("%s\n",page[temp+1]);
temp=temp+1;
}
}
}
return 0;
}
阅读全文
0 0
- Web(二维字符数组的应用)(poj)
- 二维数组的应用
- 二维数组的应用
- POJ 1656 二维树状数组简单应用
- poj 1195 二维树状数组应用实例
- c++二维数组的应用
- 二维数组的简单应用
- java 二维数组的应用
- 二维数组的转化应用
- 数组的应用和二维数组
- 指针数组与二维数组的应用
- 传递 二维 字符数组
- 字符二维数组
- 【看书】二维字符数组
- poj 2155 matrix 二维树状数组反应用
- 二维字符数组与字符串数组的使用
- poj 2155 (二维数组)
- POJ 2155 二维数组
- 界面之下:还原真实的MV*模式
- bzoj 3156: 防御准备(斜率DP)
- 【双十一献礼】动态规划入门:背包问题
- 图像处理--图像的几何变换--旋转变换
- Vue2原理浅谈
- Web(二维字符数组的应用)(poj)
- java 反射机制 之 getMethods获取所有公有方法 和 getDeclaredMethods 获取本类所有方法
- C语言基础练习14
- CodeForces
- 图像旋转使用CImage实现
- VirtualDOM与diff(Vue实现)
- codeforces 840D 主席树
- FOC控制基于电阻的电流采样方案比较
- tf.split (API r1.3)