为了账号安全,请及时绑定邮箱和手机立即绑定

顺序栈的基本操作出现一个错误

顺序栈的基本操作出现一个错误

C++
noe12138 2019-05-04 11:01:12
#include <stdio.h>#include <iostream>#include <malloc.h>using namespace std;typedef char ElemType;#define MAXSIZE 50typedef struct{ ElemType data[MAXSIZE]; int top;}SqStack;void InitStack(SqStack *&S){ S=(SqStack*)malloc(sizeof(SqStack)); S->top=0;}void DestroyStack(SqStack *&S){ free(S);}bool StackFull(SqStack *S){ if(S->top==MAXSIZE) return true; else return false;}bool StackEmpty(SqStack *S){ if(S->top==MAXSIZE) return true; else false;}bool Push(SqStack *&S,ElemType e){ if(S->top==MAXSIZE) return false; S->data[S->top]=e; S->top++; return true;}bool Pop(SqStack *&S,ElemType &e){ if(S->top==0) return false; S->top--; e=S->data[S->top]; return true;}bool GetTop(SqStack *&S,ElemType &e){ if(S->top==0) return false; e=S->data[S->top-1]; return true;}
查看完整描述

3 回答

?
onemoo

TA贡献883条经验 获得超454个赞

你的代码只有你贴出来的这些吗?  这里没有 main 函数啊!

查看完整回答
反对 回复 2019-08-10
  • noe12138
    noe12138
    谢谢,已经解答了,是main前加多了一个下划线,粗心了
  • 3 回答
  • 0 关注
  • 902 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信