正在加载图片...
template <class e> void Seqstack<E>: Push(e x)t ∥若栈不满,则将元素ⅹ插入该栈栈顶,否则溢出处理 if (IsFullo==true)overflowProcesso /棧满 elements{++top]=x;∥栈顶指针先加1,再进栈 template <class e> bool Seq Stack <E>:: Pop(E& x)i ∥/函数退出栈顶元素并返回栈顶元素的值 if(IsEmptyo-true)return falSe I X= elements[top--1;/栈顶指针 return true 退栈成功9 template <class E> void SeqStack<E>::Push(E x) { //若栈不满, 则将元素x插入该栈栈顶, 否则溢出处理 if (IsFull() == true) overflowProcess(); //栈满 elements[++top] = x; //栈顶指针先加1, 再进栈 }; template <class E> bool SeqStack<E>::Pop(E& x) { //函数退出栈顶元素并返回栈顶元素的值 if (IsEmpty() == true) return false; x = elements[top--]; //栈顶指针退1 return true; //退栈成功 };
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有