前缀式计算


#include <stdio.h>
#include <stdlib.h>
double fun()
{
    char s[20];
    if(!~scanf("%s",s))          //这样可以连续输入
        exit(0);
    switch(s[0])
    {
        case '+':return fun()+fun();
        case '-':return fun()-fun();
        case '*':return fun()*fun();
        case '/':return fun()/fun();
        default:return atof(s);
    }
}
int main()
{
    while(1)
        printf("%.2lf\n",fun());
      return 0;
}


相关文章:

  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-08
  • 2021-07-09
  • 2022-12-23
相关资源
相似解决方案