写出来运行出错,改不对,大家帮忙看看
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
#define Stack_Size 50
typedef int StackElemType;
typedef struct
{
StackElementType elem[Stack_Size];
int top;
}SeqStack;
void InitStack(SeqStack *S)
{
S->top=-1;
}
int PushEmpty(SeqStack *S)
{
if(S->top==-1)
return true;
else
return false;
}
int Push(SeqStack * S,StackElementType x)
{
if(S->top==Stack_Size-1) return(FALSE);
S->top ++;
S->elem[S->top ]=x;
return [TRUE];
}
int Pop(SeqStack * S,StackElementType *x)
{
if(S->top==-1)
return [FLASE];
else
{
*x=S->elem[S->top];
S->top--;
return(TRUE);
}
}
int main(void)
{
SeqStack s=(SeqStack *)malloc(sizeof(SeqStack)*Stack_Size);
int m,x;
InitStack(s);
Push(s,3);
Push(s,9);
Push(s,17);
Pop(s,x);
m=PushEmpty(s);
printf("%d\n",m);
free(s);
}
SeqStack *s=(SeqStack *)malloc(sizeof(SeqStack) * Stack_Size);