限定性线性表—栈队列.docVIP

  • 5
  • 0
  • 约1.15万字
  • 约 20页
  • 2018-11-30 发布于江苏
  • 举报
限定性线性表—栈队列

第3章 限定性线性表——栈和队列 3.15? #define StackSize 100; typedef struct { ? SElemType? *base; ? SElemType? *top0; ? SElemType? *top1; }TSqStack;   Status InitStack(TSqStack tws){ ? //构造一个空的双向栈 ? if (!(tws.base=(SElemType *)malloc(StackSize*sizeof(SElemType))))exit(OVERFLOW); ? tws.top0=tws.base; ? tws.top1=tws.base[StackSize-1]; ? return OK; }   Status Push(TSqStack tws, int i, SElemType x){ ? //将元素x压入双向栈tws的第i个栈中,i=0,1 ? if (tws.top0==tws.top1+1)exit(OVERFLOW); ? if (i==0) *tws.top0++=x; ? else if (i==1) *tws.top1--=x; ? else return ERROR; ? return OK; }   SElemType Pop(TSqStack tws, int i){ ? //若双向栈tw

文档评论(0)

1亿VIP精品文档

相关文档