用栈求前缀表达式值
float calPostFix(char exp[], int len)
{
float s [maxSize]; int top = -1;
for(int i = len - 1; i >= 0; --i)
{
if ('0'<= exp[i] && exp[i] <= '9')
s[++top] = exp[i] - '0';
else
{
float opnd1, pand2, result;
chat op; //接受运算符
int flag; //判断计算是否成功
opand2 = s[top--];
opand1 = s[top--];
op = exp[i];
flag = calSub(opand1, op, opand2, result);
if(flag == 0) //如果不成功
{
std::count<<"ERROR" << std::end1; //puts("ERROR")
}
s[++top] == result;
}
}
return s[top];
}