【栈与队列】SDUT练习1—传说中的数据结构
来源:互联网 发布:淘宝客一般在哪里推广 编辑:程序博客网 时间:2024/04/26 19:30
题目:点击打开链接
注意:
1、简单模拟。
2、最后多输出一行。
代码:
#include <stack>#include <string>#include <iostream>using namespace std;int main(){int oper;while(cin>>oper){stack<int> tar;for(int i=0;i<oper;i++){string modify;cin>>modify; //操作判断if(modify=="push"){int tmp;cin>>tmp;tar.push(tmp);//进栈continue;}else if(modify=="top"){if(tar.empty()){cout<<"empty"<<endl; //清空判断}else{cout<<tar.top()<<endl; }continue;}else if(modify=="pop"){if(tar.empty()){cout<<"error"<<endl;}else{tar.pop(); //删除第一个元素}continue;}}cout<<endl;//注意要求,多空一行 }return 0;}
- 【栈与队列】SDUT练习1—传说中的数据结构
- SDUT 2556 - 传说中的数据结构
- SDUT 2556 传说中的数据结构
- 传说中的数据结构 SDUT 2556
- sdut acm 传说中的数据结构
- 传说中的数据结构 (sdut oj)
- SDUT-2556 传说中的数据结构
- SDUT 2556 传说中的数据结构
- 【栈与队列】SDUT练习2—数据结构实验之栈一:进制转换
- SDUT ACM 实验九 传说中的数据结构
- 寒假第三天--栈和队列--传说中的数据结构
- 传说中的数据结构 栈
- 传说中的数据结构【栈】
- 栈学习——传说中的数据结构
- 传说中的数据结构之”栈“
- 传说中的数据结构
- 传说中的数据结构
- 传说中的数据结构
- priority_queue的使用
- android listview addHeaderView和addFooterView的注意事项
- 指针数组/数组指针
- NIO2系列二——Buffer
- Lucene Field.Stror Field.Index
- 【栈与队列】SDUT练习1—传说中的数据结构
- 驱动错误码对照表
- Mesos 安装与运行
- Linux命令basename,dirname
- Android ListView列表分组
- 【转】sqlserver CAST 和 CONVERT函数
- android下 AT调试
- Explain Mysql查询语句分析方法 以后再说
- 动态编译和静态编译