#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. QGrphicsView, QGraphicsScene 和 QGraphicsItem 的区别

    初学Qt的人会经常搞不清这三个图像类QGrphicsView, QGraphicsScene 和 QGraphicsItem,它们到底有什么区别呢? QGrphicsView类实际上是为QGraphi ...

  2. tomcat6.0安装

    tomcat的安装基本是一步一步按提示来就行了: 这里填写用户名和密码,自己一定要记住啊,下面是路径的选择 然后查看安装成功与否,打开浏览器输入 然后看到下面页面就可以了

  3. WPF之拖动项滚动条自滚动(当拖动项到达高度的边界时候滚动条自己可以上下滚动)

    参考 http://www.cnblogs.com/ListenFly/p/3281997.html Point svPoint = e.GetPosition(sv); if (sv.ActualH ...

  4. mac mysql环境配置

    安装mysql:http://www.mysql.com/downloads/ 找到 MySQL Community Edition (GPL) Community (GPL) Downloads » ...

  5. mysql insert插入新形式,再也不需要拼接多重insert啦

    注意一下,不能省略表中的任何字段.包括自增id.而且字段的顺序必须和插入表一致 原理是“表插表” INSERT INTO prod_attr select A.* from ( SELECT AS p ...

  6. pycharm使用笔记

    Basic code completion (the name of any class, method or variable) control + 空格  # 代码补全,如果跟系统spotligh ...

  7. 使用PHP发送邮件的两种方法

    使用PHP发送邮件的两种方法 May242013 作者:Jerry Bendy   发布:2013-05-24 22:25   分类:PHP   阅读:2,107 views   抢沙发     今天 ...

  8. HOSTS文件详解【win|mac】

    hosts文件是一个用于储存计算机网络中各节点信息的计算机文件.这个文件负责将主机名映射到相应的IP地址. hosts文件通常用于补充或取代网络中DNS的功能.和DNS不同的是,计算机的使用者可以直接 ...

  9. web_custom_request函数详解

    在LR中当使用HTML录制方式时,录制的脚本中主要由函数web_link().web_submit_form().web_url().web_submit_data()组成,当使用HTTP录制方式时, ...

  10. What is Heterogeneous Computing?

    http://developer.amd.com/resources/heterogeneous-computing/what-is-heterogeneous-computing/ Heteroge ...