#include"stdio.h"
#include"string.h"
#include"stdlib.h"
#include"math.h"
#define MAX 100;
#define ADD 10;
enum status{ok,fail};
//操作数
typedef struct{
int *base;
int *top;
int stacksize;
}opndstack;
//操作符
typedef struct{
char *base;
char *top;
int stacksize;
}optrstack;
//初始化操作数
enum status Initopndstack(opndstack *S){
(*S).base=(int *)malloc(MAX*sizeof(int));
if(!S->base) return fail;
S->top=S->base;
S->stacksize=MAX;
return ok;
}
//初始操作符
enum status Initoptrstack(optrstack *S){
(*S).base=(char *)malloc(MAX*sizeof(char));
if(!S->base) return fail;
S->top=S->base;
S->stacksize=MAX;
return ok;
}
//压入操作数
enum status push(opndstack *S,int e){
if(S->top-S->base>=MAX) {
S->base=(int *)realloc(S->base,(MAX+ADD)*sizeof(int));
if(!S->base) return fail;
S->top=S->base+S->stacksize;
S->stacksize+=ADD;
}
*S->top++=e;
return ok;
}
void main(){
opndstack S1;optrstack S2;
enum status m1,m2;int e;
m1=Initopndstack(&S1);
m2=Initoptrstack(&S2);
e=0;
push(&S1, e);
getchar();
}