#include<stdio.h>
#include<malloc.h>
#include<string.h>
typedef struct Stack {
char* data;
int top;
int size;
int MaxSize;
}Stack;
Stack* Creat(int MaxSize) {
Stack* s;
s = malloc(sizeof(Stack));
s->data = malloc(sizeof(Stack) * MaxSize);
s->MaxSize = MaxSize;
s->top = -1;
s->size = 0;
return s;
}
void Push(Stack *s,char data) {
if (s->top == s->MaxSize - 1) {
printf("The Stack Is Full");
return 0;
}
s->size++;
s->data[++s->top] = data;
}
char Pop(Stack* s) {
if (s->top == -1) {
printf("The Stack Is Null");
return 0;
}
s->size--;
return s->data[s->top--];
}
顺序栈的基础功能
最新推荐文章于 2024-07-13 13:36:16 发布