#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. android开发事件监听

    第一种:匿名内部类作为事件监听器类 大部分时候,事件处理器都没有什么利用价值(可利用代码通常都被抽象成了业务逻辑方法),因此大部分事件监听器只是临时使用一次,所以使用匿名内部类形式的事件监听器更合适, ...

  2. windows实时操作系统

    最近一个项目需要用windows进行实时定时操作以实现同步功能(12ms),不过由于windows是分时系统,其可供用户使用的定时器误差较大. 通过查找发现了一个ardence公司开发的一个叫做RTX ...

  3. [ZZ] cbuffer和tbuffer

    http://blog.chinaunix.net/uid-20235103-id-2578297.html Shader Model 4支持的新东西,通过打包数据可以获得更好的性能.原文转发:Sha ...

  4. Apache Storm技术实战之3 -- TridentWordCount

    欢迎转载,转载请注明出处. 介绍TridentTopology的使用,重点分析newDRPCStream和stateQuery的实现机理. 使用TridentTopology进行数据处理的时候,经常会 ...

  5. UIbutton 和UIview 切单角

    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];    btn.backgroundColor = [UIColor cya ...

  6. memory_limit session.cache_expire ecshop初始化注释说明

    memory_limit session.cache_expire ecshop初始化注释说明 memory_limit = 128M; 一个脚本所能够申请到的最大内存字节数(可以使用K和M作为单位) ...

  7. [转]LaTeX处女级入门命令语法集

    1.LaTeX文件的框架如下: \documentclass{article} \begin{document} This is the body of the article \end{docume ...

  8. Error in notifier

    sudo apt-get install libnotify-bin or 在gulpfile.js第一行插入 process.env.DISABLE_NOTIFIER = true; 禁用notif ...

  9. php配置相关

    php.ini error_reporting //配置错误的显示方式 display_errors //此项优先级高于error_reporting,如果关闭该项,会返还http状态码,如果开启,则 ...

  10. [dpdk] 读开发指南(2)(内容长期整理中)

    接续前节. 7 PMD (Poll Mode Driver) A Poll Mode Driver (PMD) consists of APIs, provided through the BSD d ...