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

#include <stdio.h>

#include <iostream>

#include <malloc.h>

using namespace std;

typedef char ElemType;

#define MAXSIZE 50

typedef 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;

}


https://img4.mukewang.com/5ccd00470001707909580788.jpg

noe12138
浏览 908回答 3
3回答

onemoo

你的代码只有你贴出来的这些吗?  这里没有 main 函数啊!
打开App,查看更多内容
随时随地看视频慕课网APP