习题课(栈队列串数组).pptVIP

  • 6
  • 0
  • 约4.93千字
  • 约 25页
  • 2016-08-25 发布于河南
  • 举报
习题课(栈队列串数组)

* * 习题3.15 const int StackSize=500; typedef struct{ ????SElemtype *base; ???? int top0, top1; ?????}TwoStack; //双向栈类型 Status InitStack(TwoStack tws) {??tws.base=new SElemtype[StackSize]; ????tws.top0=-1; ?? tws.top1=StackSize; ??return OK; } Status push(TwoStack tws,int i,SElemtype x) //x入栈,i=0表示低端栈,i=1表示高端栈 {??if(tws.top0+1==tws.top1) return OVERFLOW; //栈满 if(i==0) tws.base[++tws.top0]=x; ??else if(i==1) tws.base[--tws.top1]=x; ?? else return ERROR; ??return OK; } Status pop(TwoStack tws,int i,SElemtype x) //x出栈,i=0表示低端栈,i=1表示高端栈 {??if(i==0) {??if(tws.top0==-1

文档评论(0)

1亿VIP精品文档

相关文档