逆波兰计算器:
输入所要计算的表达式的逆波兰式,并进行计算。
如 (1-2)*(4+5)
其逆波兰式:1 2 - 4 5 + *
基础的东西,还是要多敲
如下代码中,输入的格式如:1 2 - 4 5 + * #
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define Stack_Init_Size 20
#define Stack_Increasement 10
#define Max_Buffer_Size 10
typedef double Elemtype;
typedef struct {
Elemtype *base;
Elemtype *top;
int stackSize;
}sqStack;
void initStack(sqStack *s){
s->base=(Elemtype *)malloc(Stack_Init_Size*sizeof(Elemtype));
if(!s->base)
{
exit(0);
}
s->top=s->base;
s->stackSize=Stack_Init_Size;
}
void push(sqStack *s,Elemtype e){
if(s->top - s->base>=s->stackSize){
s->base=(Elemtype *)realloc(s->