#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #define IncreSize 10 #define InitSize 10 typedef int status; typedef int Elemtype; typedef struct sStack { Elemtype *base; Elemtype *top; int StackSize; }sqStack; void InitStack(sqStack *s) { s->base = (Elemtype *)malloc(sizeof(int)*InitSize); if(!s->base) exit(0); else { s->top = s->base; s->StackSize = InitSize; //return OK; } } void Push(sqStack *s, Elemtype e) { if(s->top - s->base >= s->StackSize) { s->base = (Elemtype *)realloc(s->base,(s->StackSize + IncreSize)*sizeof(Elemtype)); //这里申请的大一些的空间; if(!s->base) exit (0); } *(s->top) = e; s->top++; //return OK; } void Pop(sqStack *s, Elemtype *e) { if(s->top == s->base) exit(0); *e = *--(s->top); // return OK; } int StackLen(sqStack s) { return(s.top - s.base); //注意这里的结果是栈中的数据个数; } //输入数字,然后根据计算法则进行求解。 int main() { char c; char str[20]; //设立一个缓冲区; int i = 0; int d,e,f; sqStack s; InitStack(&s); scanf("%c", &c); while(c != '#') { while( isdigit(c) || c == '.') { str[i++] = c; str[i] = '