#include
#include
#define ERROR 0
#define OK 1
#define STACK_INT_SIZE 10
#define STACKINCREMENT 5
typedef int ElemType;
typedef struct{
ElemType *base;
ElemType *top;
int stacksize;
}SqStack;
int InitStack(SqStack *S);
int push(SqStack *S,ElemType e);
int Pop(SqStack *S,ElemType *e);
int CreateStack(SqStack *S);
void PrintStack(SqStack *S);
int InitStack(SqStack *S){
S->base=(ElemType *)malloc(STACK_INT_SIZE *sizeof(ElemType));
if(!S->base) return ERROR;
S->top=S->base;
S->stacksize=STACK_INT_SIZE;
return OK;
}
int Push(SqStack *S,ElemType e){
*S->base=e;
*S->top=S->stacksize;
S->stacksize--;
}
int Pop(SqStack *S,ElemType *e){
}
int CreateStack(SqStack *S){
int e;
if(InitStack(S))
printf("Init Success!\n");
else{
printf("Init Fail!\n");
return ERROR;
}
printf("input data:(Terminated by inputing a character)\n");
while(scanf("%d",&e))
Push(S,e);
return OK;
}
void PrintStack(SqStack *S){
ElemType e;
while(Pop(S,&e))
printf("=",e);
}
int main(){
SqStack ss;
printf("\n1-createStack\n");
CreateStack(&ss);
printf("\n2-Pop&Print\n");
PrintStack(&ss);
return 0;
}