首页 > 试题广场 >

设顺序栈如左图所示。

[问答题]

设顺序栈如左图所示。

其中结点定义如下: top

typedef  struct {

Elemtype  *base;  // 栈底指针

Elemtype  *top;   // 栈顶指针

}Stack;

设计算法,将栈顶元素出栈并存入 e 中. base

Status Pop(SqStack *S,SElemType *e) { if(S->top==-1) return ERROR; *e=S->data[S->top]; S->top--; return OK; }
发表于 2019-04-20 17:03:09 回复(0)

void pop(Stack &S,Elemtype &e)

{

if(S.top==S.base) return ERROR;

S.top--;

e=*s.top;

}
发表于 2017-05-14 22:18:42 回复(0)