#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<typeinfo>
#include<sstream>
#include<fstream>
#include<algorithm>
using namespace std;
char a[101];
float calculate(){ //求h[n]
scanf("%s",a); //无视空格
switch(a[0]){
case '+':return calculate() + calculate();
case '-':return calculate() - calculate();
case '*':return calculate() * calculate();
case '/':return calculate() / calculate();
default : return atof(a);
}
}
int main()
{
//流程图!!
cout << "输入:";
printf("%.6lf",calculate());
//cout << calculate();
return(0);
}
//cout << "输入:";
练习1 - 逆波兰表达式
最新推荐文章于 2023-08-16 20:18:42 发布