#include<stdio.h>
#include<stdlib.h>
typedef struct{ //符号栈
char *base;
char *top;
}optrstack;
typedef struct{ //数栈
int *base;
int *top;
}opndstack;
void initoptr(optrstack *s) //初始化符号栈
{
s->base=(char *)malloc(100*sizeof(char));
s->top=s->base;
}
void initopnd(opndstack *s) //初始化数栈
{
s->base=(int *)malloc(100*sizeof(int));
s->top=s->base;
}
char gettopoptr(optrstack *s) //取符号栈栈顶元素
{
char e;
e=*(s->top-1);
return e;
}
int gettopopnd(opndstack *s) //取数栈栈顶元素
{
int e;
e=*(s->top-1);
return e;
}
void pushoptr(optrstack *s,char e) //将符号压入栈
{
*(s->top)=e;
s->top++;
}
void pushopnd(opndstack *s,int e) //将数压入栈
{
*(s->top)=e;
s->top++;
}
char popoptr(optrstack *s) //栈顶符号出栈
{
char e;
s->top--;
e=*s->top;
return e;
}
int popopnd(opndstack *s) //栈顶数出栈