cpp;gutter:true;</p>
<h1>include</h1>
<h1>include</h1>
<h1>include</h1>
<h1>define MAXSIZE 20</h1>
<h1>define ERROR 0</h1>
<h1>define OVERFLOW 0</h1>
<h1>define OK 1</h1>
<p>typedef int SElemType;</p>
<p>typedef int status;</p>
<p>typedef struct{</p>
<p>SElemType *base;</p>
<p>SElemType *top;</p>
<p>int stacksize;</p>
<p>}Sqstack;</p>
<p>status InitStack(Sqstack &S){</p>
<p>S.base=new SElemType[MAXSIZE];</p>
<p>if(!S.base)exit(OVERFLOW);</p>
<p>S.top=S.base;</p>
<p>S.stacksize=MAXSIZE;</p>
<p>return OK;</p>
<p>}</p>
<p>status Push(Sqstack &S,SElemType &e){</p>
<p>if(S.top-S.base==S.stacksize)return ERROR;</p>
<p>*S.top++=e;</p>
<p>return OK;</p>
<p>}</p>
<p>status Pop(Sqstack &S,SElemType &e){</p>
<p>if(S.top==S.base)return ERROR;</p>
<p>e=*--S.top;</p>
<p>return e;</p>
<p>}</p>
<p>void main()</p>
<p>{</p>
<p>Sqstack S;</p>
<p>InitStack(S);</p>
<p>SElemType e;</p>
<p>SElemType E;</p>
<p>cout<>e;</p>
<p>while(e){</p>
<p>E=e%8;</p>
<p>Push(S,E);</p>
<p>e=e/8;}</p>
<p>cout<>e;</p>
<p>int i=0;</p>
<p>while(e){</p>
<p>E=(e%10)*pow(8,i);</p>
<p>Push(S,E);</p>
<p>e=e/10;</p>
<p>i++;</p>
<p>}</p>
<p>cout<
Original: https://www.cnblogs.com/linlinmailbox/p/16492811.html
Author: 霖霖的信箱
Title: 数据结构 栈与队列
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/607365/
转载文章受原作者版权保护。转载请注明原作者出处!