清华大学数据结构3.docVIP

  • 6
  • 0
  • 约 15页
  • 2017-03-22 发布于江苏
  • 举报
清华大学数据结构3

清华大学数据结构3 第三章 栈与队列 3.15 typedef struct{ Elemtype *base[2]; Elemtype *top[2]; }BDStacktype; //双向栈类型 Status Init_Stack(BDStacktype tws,int m)//初始化一个大小为m的双向栈tws { tws.base[0]=(Elemtype*)malloc(sizeof(Elemtype)); tws.base[1]=tws.base[0]+m; tws.top[0]=tws.base[0]; tws.top[1]=tws.base[1]; return OK; }//Init_Stack Status push(BDStacktype tws,int i,Elemtype x)//x入栈,i=0表示低端栈,i=1表示高端栈 { if(tws.top[0]tws.top[1]) return OVERFLOW; //注意此时的栈满条件 if(i==0) *tws.top[0]++=x; else if(i==1) *tws.top[1]--=x; else return ERROR; return

文档评论(0)

1亿VIP精品文档

相关文档