正在加载图片...
③相关的操作实现 Status InitStack Sq(sqstack &s)i S base=( SElem Type *)malloc(STACK INIT SIZE*sizeof( SElem Type)); if(!S base )exit(OVERFLOW) S top=S base S. stacksize STACK INIT SIZE: return OK 3 //InitStack Status GetTop Sq(sqstack S, Selem Type &e) if(Stop==S base)return ERROR e=*(S top-1); return OK; Status Push Sq(sqStack &s, selem Type e) 栈满、栈空? S top Status Pop sq(sqstack s, SelemType &e)f Stop; pboustc. edu. cn 6 中国科学技术大学ypb@ustc.edu.cn 6 中国科学技术大学 Status InitStack_Sq(SqStack &S) { S.base=(SElemType *)malloc(STACK_INIT_SIZE*sizeof(SElemType)); if(!S.base)exit(OVERFLOW); S.top=S.base; S.stacksize=STACK_INIT_SIZE; return OK; } //InitStack_Sq Status GetTop_Sq(SqStack S,SelemType &e){ if(S.top==S.base)return ERROR; e=*(S.top-1);return OK; } Status Push_Sq(SqStack &S ,SelemType e) { … *S.top++=e; … } Status Pop_Sq(SqStack S ,SelemType &e){ … e=*--S.top; … } 相关的操作实现 栈满、栈空?
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有