C语言数据结构之栈的基本操作,栈的各种操作

C语言数据结构之栈的基本操作

一.程序结构图

1-60-jpg_6_0_______-90-0-0-90.jpg

1-46-jpg_6_0_______-94-0-60-94.jpg

1-46-jpg_6_0_______-88-0-106-88.jpg

.算法及其功能函数

1-46-jpg_6_0_______-69-0-152-69.jpg

InitStack(SqStack *S)

1-46-jpg_6_0_______-55-0-198-55.jpg

1-46-jpg_6_0_______-71-0-244-71.jpg

1-46-jpg_6_0_______-117-0-290-117.jpg

1-46-jpg_6_0_______-123-0-336-123.jpg

/*创建栈*/

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;

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐