数据结构c语言栈的基本操作实验报告,C语言数据结构之栈的基本操作
C语言数据结构之栈的基本操作,栈的各种操作C语言数据结构之栈的基本操作一.程序结构图二.算法及其功能函数InitStack(SqStack *S)/*创建栈*/GetTop(SqStack *S,SElemType e)/*取栈顶元素并用e返回*/ Push(SqStack *S,SElemType e)/*插入e为栈顶元素*/ Po...
C语言数据结构之栈的基本操作,栈的各种操作
C语言数据结构之栈的基本操作
一.程序结构图


二

.算法及其功能函数

InitStack(SqStack *S)




/*创建栈*/
GetTop(SqStack *S,SElemType e) /*取栈顶元素并用e返回*/ Push(SqStack *S,SElemType e) /*插入e为栈顶元素*/ Pop(SqStack *S,SElemType *e) /*删除栈顶元素并用e返回*/ StackEmpty(SqStack S) /*判断栈是否为空*/ StackLength(SqStack S) /*求栈的长度*/ Nizhi(SqStack S) /*将栈中元素逆置*/ 三.源代码
#include
#include
#define OK 1
#define OVERFLOW -2
typedef int Status;
typedef int SElemType;
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef struct{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
Status InitStack(SqStack *S)
{
int i,n; SElemType e;
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)