出栈函数如下:Status Pop(SqStack &S,SElemType &e){if (S.top==S.base)return ERROR;e=*--S.top;return OK;}为什么是e=*--S.top; 而不是e=*S.top; e=*--S.top不就是取顶元素的下面那个元素么?有点混

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/08 08:03:28
出栈函数如下:Status Pop(SqStack &S,SElemType &e){if (S.top==S.base)return ERROR;e=*--S.top;return OK;}为什么是e=*--S.top; 而不是e=*S.top; e=*--S.top不就是取顶元素的下面那个元素么?有点混

出栈函数如下:Status Pop(SqStack &S,SElemType &e){if (S.top==S.base)return ERROR;e=*--S.top;return OK;}为什么是e=*--S.top; 而不是e=*S.top; e=*--S.top不就是取顶元素的下面那个元素么?有点混
出栈函数如下:
Status Pop(SqStack &S,SElemType &e){
if
(S.top==S.base)return ERROR;
e=*--S.top;
return OK;
}
为什么是e=*--S.top; 而不是e=*S.top;
e=*--S.top不就是取顶元素的下面那个元素么?有点混

出栈函数如下:Status Pop(SqStack &S,SElemType &e){if (S.top==S.base)return ERROR;e=*--S.top;return OK;}为什么是e=*--S.top; 而不是e=*S.top; e=*--S.top不就是取顶元素的下面那个元素么?有点混
因为你的栈的设计中,栈顶标志top是指向栈顶元素上面一个位置的