SDUT 2556 - 传说中的数据结构
来源:互联网 发布:php抓取微信文章 编辑:程序博客网 时间:2024/05/06 23:58
传送门SDUT 2556 - 传说中的数据结构
本来是直接去做UVA的模拟栈的题的, 没思路不用说, 别人的解题报告也根本看不懂.
后来想想还是我太心急了, 栈是什么都不是很清楚, 没有学会走路就想飞.
所以就先做点题目, 熟悉一下.
争取清明之前把栈, 队列, 二叉树搞清楚. 至少能看懂别人的代码.
#include <cstdio>#include <stack>#include <cstring>using namespace std;#define MAXN 2000int main(){ //freopen("input.txt", "r", stdin); int n; while (scanf("%d", &n) == 1) { getchar(); int i, j; char temp[1000]; int target[MAXN], top = -1; for (i = 0; i < n; i++) { scanf("%s", temp); if (strcmp(temp, "push") == 0) { scanf("%d", &target[++top]); } else if (strcmp(temp, "top") == 0) { if (top == -1) printf("empty\n"); else printf("%d\n", target[top]); } else if (strcmp(temp, "pop") == 0) { if (top == -1) printf("error\n"); else top--; } } printf("\n"); } return 0;}
0 0
- SDUT 2556 - 传说中的数据结构
- SDUT 2556 传说中的数据结构
- 传说中的数据结构 SDUT 2556
- SDUT-2556 传说中的数据结构
- SDUT 2556 传说中的数据结构
- sdut acm 传说中的数据结构
- 传说中的数据结构 (sdut oj)
- SDUT ACM 实验九 传说中的数据结构
- 【栈与队列】SDUT练习1—传说中的数据结构
- 【2556】传说中的数据结构 sdutOJ
- 山理工2556 传说中的数据结构
- 传说中的数据结构
- 传说中的数据结构
- 传说中的数据结构
- 传说中的数据结构
- 传说中的数据结构
- 传说中的数据结构
- 传说中的数据结构
- 一起学Java设计模式--简单工厂模式(不在23中设计模式之内)
- wince驱动开发人员必看的绝世好文章:Memory marshalling in Windows CE( Windows CE的内存地址重构),
- 串口插拔自动检测程序思路
- 浅谈Jsp中隐式对象中Session的生命中期及设置失效时间问题
- 使用Unity 创建自己的android AR 项目
- SDUT 2556 - 传说中的数据结构
- HTML5 CSS3网站在老IE中也能正常显示的方法
- asp.net使用plupload实现文件上传
- 20140403收盘小结
- 马方称发现涉失联客机强有力线索 暂不公开
- java.lang.ClassNotFoundException: org.apache.hadoop.hbase.mapreduce.TableOutputFormat解决办法
- Oracle操作
- makefile--函数
- POJ 2778 AC自动机+矩阵相乘