#include "sqstack.h"
Status InitStack(Stack &S)
{
SElemType *data=new SElemType;
S.top=-1;
return true;
}
Status DestroyStack(Stack &S)
{
delete S.data;
return true;
}
Status StackEmpty(Stack &S)
{
if(S.top==-1)
return true;
else
return false;
}
Status Push(Stack &S,SElemType &e)
{
if(S.top==MaxSize-1)
return false;
S.top++;
S.data[S.top]=e;
return true;
}
Status Pop(Stack &S,SElemType &e)
{
if(S.top==-1)
return false;
e=S.data[S.top];
S.top--;
return true;
}
数据结构
最新推荐文章于 2024-07-27 16:10:46 发布
本文详细介绍了栈数据结构的基本操作,包括初始化、销毁、空栈判断、元素压入和弹出。通过实例展示了如何使用这些操作进行栈的管理。
357

被折叠的 条评论
为什么被折叠?



