#include "stdio.h"
#include "stdlib.h"
#include "io.h"
#include "math.h"
#include "time.h"
#define MAXSIZE 20 /* 存储空间初始分配量 */
typedef int Status;
typedef int SElemType; /* SElemType类型根据实际情况而定,这里假设为int */
typedef struct{
SElemType date[MAXSIZE];
int top;
}SqStack;
Status Initstack(SqStack *S)
{
S.top=-1;
return 1;
}
Status ClearStack(SqStack *S)
{
S.top=-1;
return 1;
}
Status StackEmpty(Sqstack S)
{
if(S.top==-1)
return 1;
else
return o;
}
int Stacklength(SqStack S)
return (S.top+1);
}
Status GetTop(SqStack S,ElemType &e)
{
if(S.top==-1)
return 0;
else
e=S.date[top]
return 1;
}
Status Push(SqStack *S,ElemType e)
{
if(S.top==MAXSIZE-1)
return 0;
else
S.date[++S.top]=e;
return 1
}
Status Pop(SqStack *s,ElemType &e)
{
if(S.top==-1)
return 0;
else
e=S.date[S.top--];
return 1;
}
进击的数据结构三之栈的顺序存储结构
最新推荐文章于 2024-01-24 19:03:42 发布