![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
郭某
这个作者很懒,什么都没留下…
展开
-
由两个人栈组成的队列
题目:编写一个类,用两个栈实现队列,支持队列的基本操作。 思想: 1.如果stackpop为空时,才能将stackpush中的数据压入stackpop中; 2.如果要将stackpush中的数据压入stackpop中,那么必须一次性将stackpush所有数据压入stackpop。 #include #include typedef struct Stack { int原创 2016-11-09 21:32:58 · 240 阅读 · 0 评论 -
设计一个有getMin功能的栈
题目: 实现一个特殊的栈,在实现栈的基本功能基础上,在实现返回栈中最小元素的操作。 代码: #include #include typedef struct stack { int data[100]; int top; }Stack,*pStack; //初始化顺序栈 void InitStack(pStack pstack) { pstack->to原创 2016-11-09 09:39:54 · 230 阅读 · 0 评论 -
双栈队列练习题
编写一个类,只能用两个栈结构实现队列,支持队列的基本操作(push,pop)。给定一个操作序列ope及它的长度n,其中元素为正数代表push操作,为0代表pop操作,保证操作序列合法且一定含pop操作,请返回pop的结果序列。测试样例:[1,2,3,0,4,0],6返回:[1,2] class TwoStack { stack stackpush; stack stackpo原创 2016-11-11 10:22:07 · 214 阅读 · 1 评论