两个栈实现队列
来源:互联网 发布:淘宝从哪里看消费总额 编辑:程序博客网 时间:2024/05/16 17:20
template<typename T>class CQueue{public:CQueue();~CQueue();void appendTail(const T&node);T deleteHead();private:stack<T>stack1;stack<T>stack2;};template<typename T>CQueue<T>::CQueue(){}template<typename T>CQueue<T>::~CQueue(){}template<typename T>void CQueue<T>::appendTail(const T& temp){stack1.push(temp);}template<typename T>T CQueue<T>:: deleteHead(){if (stack2.size() <= 0){while (stack1.size() > 0){T &data = stack1.top();stack1.pop();stack2.push(data);}}if (stack2.size() == 0){throw new exception("empty");}T head = stack2.top();stack2.pop();return head;}
0 0
- 两个栈实现队列
- 两个队列实现栈
- 两个栈实现队列
- 两个栈实现队列
- 两个栈实现队列
- 两个队列实现栈
- 两个栈实现队列
- 两个 栈 实现队列
- 两个栈实现队列
- 两个队列实现栈
- 两个栈实现队列
- 两个栈实现队列
- 两个队列实现栈
- 两个栈实现队列
- 两个栈实现队列
- 两个栈实现队列
- 队列--两个栈实现
- 两个队列实现栈
- javascript修改css的class名字
- java中回调
- ural 1203. Scientific Conference(贪心or dp)
- dia的安装过程
- (C++Primer)[C++]多行注释标记原则
- 两个栈实现队列
- centos 5.3中文系统乱码问题
- 日期
- inline hook【002】
- c#项目中用到的两种接口 webservice 和wcf
- 简单谈谈对目前项目组组织形态的感受
- Python Learning——第一天
- Android Lint工具学习
- 编程之美2.13 子数组的最大乘积