将运算符前置的一种表达式。很简单,没什么要具体说明的。逐个拆就行。
#include<iostream>
using namespace std;
double notation(){
char str[10];
cin >> str;
switch (str[0]){
case '+':return notation() + notation();
case '-':return notation() - notation();
case '*':return notation() * notation();
case '/':return notation() / notation();
default:return atof(str);//将字符串转换为float型
}
}
int main(){
cout << notation() << endl;
system("pause");
return;
}