p; }
else{
NumA = FTop(Operands);
FPop(Operands);
if (NumB == 0){
PrintError = 1; /*分母不为0*/
}
else{
answer = (float)(NumA / NumB); /* x / y*/
FPush(answer,Operands);
}
}
break;
case '+': /*加法运算*/
NumB = FTop(Operands);
FPop(Operands);
if (FIsEmpty(Operands)){
PrintError = 1;
}
else{
NumA = FTop(Operands);
FPop(Operands);
answer = NumA + NumB; /* x + y*/
FPush(answer,Operands);
}
break;
case '-': /*减法运算*/
NumB = FTop(Operands);
FPop(Operands);
if (FIsEmpty(Operands)){
PrintError = 1;
}
else{
NumA = FTop(Operands);
FPop(Operands);
answer = NumA - NumB; /* x - y*/
FPush(answer,Operands);
}
break;
default:
PrintError = 1;
break;
} /*判断结束*/
Pop(Whereat);
}
} /*循环结束*/
if (!PrintError){
answer = FTop(Operands);
FPop(Operands);
if (FIsEmpty(Operands) != 1){
fprintf(Change,"Error in infix notation."); /*如果还有操作数*/
PrintError = 0;
}
else
fprintf(Change,"%.2f",answer);
}
else{
fprintf(Change,"Error in infix notation.");
PrintError = 0;
}
FMakeEmpty(Operands);
free(Operands);
}