28-题目1108:堆栈的使用
2016-03-03 19:43
393 查看
http://ac.jobdu.com/problem.php?pid=1108
题目比较简单#include<stdio.h> #include<string.h> #include<fstream> #include<iostream> using namespace std; int main(){ int n; ifstream cin("data.txt"); while (cin >> n && n !=0 ) { int i, tail = -1; char operation; int *stack = new int ; for (i = 0; i < n; i++) { cin >> operation; if (operation == 'P') cin >> stack[++tail]; else if (operation == 'O') { if (tail == -1) tail = -1; else tail--; } else if (operation == 'A') //查询 { if (tail >= 0) cout << stack[tail] << endl; else cout << "E" << endl; } } cout << endl; } system("pause"); return 0; }
相关文章推荐
- spoj 2319 BIGSEQ - Sequence
- C语言++a与a++的实现机制与操作符结合优先级
- JMS
- 2015年大二上-数据结构-查找-1-(1)-线性表的折半查找
- 安卓图片加载之使用universalimageloader加载圆形圆角图片
- rsync
- inotify
- 错误处理与异常抛出_Swift基础知识学习
- 一维DFT
- CF(441D Valera and Swaps)置换群
- 每周算法讲堂 快速幂
- bzoj4410 [Usaco2016 Feb] Fence in
- 电容补偿技术的作用(转载)
- Leetcode:101. Symmetric Tree(JAVA)
- Redis源码学习(一)内存管理
- JNI数据类型
- Android 自定义View(一) 介绍和一个简单TextView显示
- 卷积神经网络
- 终端-进入云服务器
- 电工刀安全操作方法(转载)