复习日历-2018/7/26晚19:30
测试代码
#include <stdio.h>
#include <stdlib.h>
typedef int ElemType;
#define MAXSIZE 100
typedef struct seqStack{
ElemType stack[MAXSIZE];
int top;
}seqStack; //栈的数据类型的定义
void initSeqStack(seqStack *L);
int seqStackPush(seqStack *L,ElemType e);
int seqStackPop(seqStack *L);
int main()
{
seqStack L;
initSeqStack(&L);
seqStackPush(&L,1);
seqStackPush(&L,2);
seqStackPop(&L);
return 0;
}
//初始化顺序栈
void initSeqStack(seqStack *L){
L->top = 0;
printf("initSeqStack is ok!\n");
}
//入栈
int seqStackPush(seqStack *L,ElemType e){
if(L->top >= MAXSIZE){
return 0;
}
L->stack[L->top] = e;
L->top++;
printf("push %d is ok!\n",e);
return 1;
}
//出栈
int seqStackPop(seqStack *L){
if(L->top <= 0){
return 0;
}
L->top--;
printf("seqStackPop %d is ok!\n",L->stack[L->top]);
return 1;
}