介个没有问题啊,为什么编译就是不成功呢。。
#include"stdio.h"
#include"math.h"
#include"time.h"
#include"io.h"
#include"stdlib.h"
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define MAXSIZE 20
typedef int Status;
typedef int SElemType;
typedef struct StackNode
{
SElemType data;
struct StackNode *next;
}StackNode;*LinkStackPtr;
typedef struct
{
LinkStackPtr top;
int count;
}LinkStack;
//链栈结构
Status visit(SElemType c)
{
printf("%d\n",c);
return OK;
}
Status InitStack(LinkStack *S)
{
S->top=(LinkStackPtr)malloc(sizeof(StackNode));
if(!S->top)
return ERROR;
S->top=NULL;
S->count=0;
return OK;
}//构建一个空栈
Status ClearStack(LinkStack *s)
{
LinkStackPtr p,q;
p=s->top;
while(p)
{
p=q;
p=p->next;
free(q);
}
s->count=0;
return OK;
}//使栈变为空栈
Status EpmtyStack(LinkStack s)
{
if(s.count==0)
return TRUE;
else
return FALSE;
}//判断栈是否为空栈
int StackLength(LinkStack s)
{
return s.count;
}//返回s中数据元素个数
Status GetTop(LinkStack s,SElemType *e)
{
if(s.top===NULL)
return ERROR;
else
*e=s.top->data;
return OK;
}//用e返回s中的栈顶元素
Status Push(LinkStack *S,SElemType e)
{
LinkStackPtr s=(LinkStackPtr)malloc(sizeof(StackNode));
s->data=e;
s->next=S->top;
S->top=s;
S->count++;
return OK;
}//向栈中插入一个元素e
Status Pop(LinkStack *S,SElemType *e)
{
LinkStack p;
if(EpmtyStack(S))
return ERROR;
*e=S->top->data;
p=S->top;
S->top=S->top->next;
free(p);
S->count--;
return OK;
}//删除栈顶元素
Status StackTraverse(LinkStack s)
{
LinkStackPtr p;
p=s.top;
while(p)
{
visit(p->data);
p=p->next;
}
return OK;
}//输出S中所有数据元素
int main()
{
LinkStack s;
int j;
int e;
if(InitStack(*s)==OK)
{
for(j=0;j<=5;j++)
{
Push(*s,j);
}
}
printf("栈中元素为: ",StackTraverse(s));
printf("栈的长度:%d\n",StackLength(s));
Pop(*s,*e);
printf("栈是否为空:(1,是;0,否)",EpmtyStack(s));
GetTop(s,*e);
printf("栈长为:%d\n",StackLength(s));
ClearStack(*s);
printf("是否为空栈:(1,是;0,否)",EpmtyStack(s));
return O;
}
还说没错,你编译时看看都是些什么错误提示,挨个改啊
开始没几行就有个
}StackNode,*LinkStackPtr; // StackNode 和 *LinkStackPtr 用 , 分隔,而不是 ;
另外很多,,全角和半角混用的逗号,自己都先改好那些吧