#include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>
#include <string>

using namespace std;

int main()
{
char command[16];
char url[71];

stack<string> forwardStack;
stack<string> backStack;

string curUrl = "http://www.acm.org/";
backStack.push(curUrl);

while (true)
{
gets_s(command);

if (strcmp(command, "QUIT") == 0)
{
break;
}
else if (strcmp(command, "VISIT") == 0)
{
gets_s(url);
curUrl = url;
backStack.push(curUrl);

puts(curUrl.c_str());
puts("\n");
}
else if (strcmp(command, "BACK") == 0)
{
if (backStack.empty())
{
puts("Ignored\n");
}
else
{
forwardStack.push(curUrl);
backStack.pop();
if (!backStack.empty())
{
curUrl = backStack.top();
puts(curUrl.c_str());
puts("\n");
}
else
{
puts("Ignored\n");
}

}

}
else if (strcmp(command, "FORWARD") == 0)
{
if (forwardStack.empty())
{
puts("Ignored\n");
}
else
{
backStack.push(curUrl);
forwardStack.pop();
if (!forwardStack.empty())
{
curUrl = forwardStack.top();
puts(curUrl.c_str());
puts("\n");
}
else
{
puts("Ignored\n");
}

}

}

}

}

POJ 1028解答的更多相关文章

  1. poj 1028

    http://poj.org/problem?id=1028 题意(水):做一个游览器的历史记录. back:后退到上一个页面,当上一个页面没有时,输出ignored. forward:向前一个页面, ...

  2. poj 1028 Web Navigation(模拟)

    题目链接:http://poj.org/problem? id=1028 Description Standard web browsers contain features to move back ...

  3. poj 1028 Web Navigation

    Web Navigation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31088   Accepted: 13933 ...

  4. poj 1028 Web Navigation 【模拟题】

    题目地址:http://poj.org/problem?id=1028 测试样例: Sample Input VISIT http://acm.ashland.edu/ VISIT http://ac ...

  5. POJ 1028题目描述

    Description Standard web browsers contain features to move backward and forward among the pages rece ...

  6. POJ 1028 Web Navigation 题解

    考查代码能力的题目.也能够说是算法水题,呵呵. 推荐新手练习代码能力. 要添加难度就使用纯C实现一下stack,那么就有点难度了,能够使用数组模拟环形栈.做多了,我就直接使用STL了. #includ ...

  7. 【stack】模拟网页浏览 poj 1028

    #include<stdio.h> #include<string.h> int main() { ][]; ]; int i,depth; strcpy(s[]," ...

  8. POJ 1028:Web Navigation

    Web Navigation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 30828   Accepted: 13821 ...

  9. FJUTOJ-周赛2016-12-16

    注:fjutoj基本每周都有一次周赛,欢迎大家都来参加! 网址:http://59.77.139.92/index.jsp A题:来源 POJ 2773 题意:给两个数m和k,问第k 个和m 互素的数 ...

随机推荐

  1. hdu Largest Rectangle in a Histogram

    这道题目是一道动态规划的题目,动态规划的点不在面积上,而在每个矩形可左右扩展的坐标上.找出每个矩形最左边和最右边比它高的矩形的下标,最后求面积即可: #include"stdio.h&quo ...

  2. 如何设置NBU的Backup, Archive and Restore

    第一行表示Master Server 第二行猜测表示当前主机 第三行不清楚   总结: 1. 这里压根就没有Media Server的事, Media Server对整个备份系统来说是透明的. 2. ...

  3. 字符编解码的故事(ASCII,ANSI,Unicode,Utf-8区别)

    (关于字符编码的深入解释,请参见我的原创文章<关于字符编码,你所需要知道的>.) 此文为转载,有少许修订,原文出处不详. 很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同 ...

  4. 【翻译】CEDCE2010 制作魅力绘制而要知道的光学小知识

    关于Silicon Studio 个人觉得他们的后处理技术在国际上还是有相对水准的,而且不少日系游戏也采用了他们的全平台YEBIS 3的中间件.   YEBIS 3的特性可以看下这个  http:// ...

  5. Oracle Merge Into 用法详解

    原文:http://blog.csdn.net/EdgenHuang/article/details/3587912 Oracle9i引入了MERGE命令,你能够在一个SQL语句中对一个表同时执行in ...

  6. Bootstrap页面布局11 - BS表单

    表单之 文本框 text <input type='text' value='' placeholder='输入您的用户名' class='input-mini' /> ①几个类控制文本框 ...

  7. VS 本机调试

    VS~通过IIS网站启用"域名"调试 在我们开发网站时,对某些信息进行序列化时,通常使用session,cookies,nosql等技术,而为了安全,我们在服务器上很多情况都做了防 ...

  8. 256 terabytes random-access memory

    Computer Systems A Programmer's Perspective Second Edition As we will discuss, the extension of IA32 ...

  9. java FileWriter and FileReader

    import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class FWFRD ...

  10. what a fuck postgre update sql

    ================= what a fuck postgre update sql ================= UPDATE temp_group_temp set group_ ...