fw-3.5 - queue by 2 stacks - C++ version - 2013年12月16日21:20:06
来源:互联网 发布:最新恩比德身体数据 编辑:程序博客网 时间:2024/04/29 02:30
#include <iostream>#include <stack>using namespace std;class queueby2stacks{ stack<int> * front_stack;stack<int> * back_stack;public: queueby2stacks(){front_stack = new stack<int>();back_stack = new stack<int>();}void enqueue(int i){front_stack->push(i);}int dequeue(){if (back_stack->size() == 0){if (front_stack->size() == 0){cout << "queue is empty" << endl;return -1;}else{while (front_stack->size()!=0){int ele = front_stack->top();front_stack->pop();back_stack->push(ele);}int tempele = back_stack->top();back_stack->pop();return tempele;}}else{int element = back_stack->top();back_stack->pop();return element;}}};int main(){cout << "this is the test" << endl;queueby2stacks qtostack;for (int i = 0; i < 10; ++i){qtostack.enqueue(i);}for (int j = 0; j < 11; ++j){cout << qtostack.dequeue() << endl;;}}
0 0
- fw-3.5 - queue by 2 stacks - C++ version - 2013年12月16日21:20:06
- fw 3.5 -2013年12月16日21:02:12 - two stacks make a queue- java version -
- fw-2013年12月16日19:48:30 - haino tower - C++ version
- fw 3.6 - stack sort- java version - 2013年12月16日23:23:32
- FW-4.2- decide whether the two nodes have circle - JAVA VERSION - 2013年12月20日20:22:25
- FW-binary - tree - with id and sibling connected - java version 2013年12月18日1:21
- fw - dfs: stack/recursive ; bfs : stack/recursive- java version - 2013年12月20日18:37:18
- fw - pre_order_traverse - 2013年12月17日13:36:58 - java version
- fw-2013年12月16日16:54:13 - haino tower via stack -java
- fw ->>>>>>> 2013年12月13日23:16:30 ->> quick_sort
- fw 2013年12月14日12:51:42 selection_sort
- FW - java - Adjacency list- 2013年12月19日15:42:04- BFS - edge Node
- fw -BFS & DFS tree-2-013年12月17日17:56:33
- 2015年7月11日-FW
- implement-queue-by-two-stacks
- Implement Queue by Two Stacks
- Implement Queue by Two Stacks
- Implement Queue by Two Stacks
- hbase中关于scan的操作
- 做seo要有的4种意识
- 将资源写入磁盘文件
- 8天学通MongoDB——第一天 基础入门
- solr高亮(highlight),拼写检查(spellCheck),匹配相似(moreLikeThis) 应用实践
- fw-3.5 - queue by 2 stacks - C++ version - 2013年12月16日21:20:06
- arm-linux-gcc参数项讲解
- Ljava.lang.String 异常
- (POJ DP1.1)POJ 1949 Chores(简单DP)
- poj 1847 Tram
- 8天学通MongoDB——第二天 细说增删查改
- MVC控制器Action的返回类型
- iOS7 xcode5 百度地图Api出现-[__NSCFString stringFromMD5]: unrecognized selector sent to instance 0x14d5211
- 将串口服务器联入外网