分析:题目中说用栈实现,我觉得这样很麻烦,就用了一个数组+指针解决了.其实就是大模拟.

#include <stack>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; string s, ss;
stack <string> s1, s2;
string q[];
int cnt = , maxx = ; int main()
{
q[] = "http://www.acm.org/";
while (cin >> s && s != "QUIT")
{
if (s == "VISIT")
{
cin >> ss;
q[++cnt] = ss;
maxx = cnt;
cout << ss << endl;
}
else
if (s == "BACK")
{
if (cnt - <= )
printf("Ignored\n");
else
{
cnt--;
cout << q[cnt] << endl;
}
}
else
{
if (cnt + > maxx)
printf("Ignored\n");
else
{
cnt++;
cout << q[cnt] << endl;
}
}
}
return ;
}

最新文章

  1. C# 基础排序与查找算法
  2. N的阶乘末尾0的个数和其二进制表示中最后位1的位置
  3. 第一周Web类WriteUp
  4. nginx 配置多个二级域名
  5. mtool安装
  6. 接入新浪、腾讯微博和人人网的Android客户端实例 接入新浪、腾讯微博和人人网的Android客户端实例
  7. STL 源代码剖析 算法 stl_algo.h -- partition
  8. Jmeter之基本介绍
  9. panic和recover的使用规则
  10. 学生ID查询
  11. 《剑指offer》字符串的排列
  12. sass动态实现颜色平铺显示
  13. API测试:Chai &amp; Mocha
  14. (Catalan数 大数) Game of Connections poj2084
  15. java中静态代码执行顺序
  16. 题解——洛谷P3390 【模板】矩阵快速幂(矩阵乘法)
  17. [从零开始搭网站三]CentOS配置JDK
  18. Java理论学时第五节。课后作业。
  19. 请教如何用ASP.NET实现http://abc.com/orderID这样的URL???
  20. MySQL 存储过程传参数实现where id in(1,2,3,...)示例

热门文章

  1. bzoj3105 [cqoi2013]新Nim游戏——贪心+线性基
  2. QT Creater环境搭建
  3. bzoj4668
  4. bzoj4561
  5. shell脚本-数组
  6. JS连续滚动幻灯片:原理与实现
  7. python配置文件编写
  8. 2 我们的C#学习方法
  9. .net framework 3.5 安装报错 0x800F0954问题
  10. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &#39;empid&#39; in &#39;class cn.happy.entity.Emp&#39;