* + 11.0 12.0 + 24.0 35.0
1357.000000
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 using namespace std; 5 char a[1001]; 6 double ans; 7 double f() 8 { 9 cin>>a; 10 if(a[0]>=‘0‘&&a[0]<=‘9‘) 11 { 12 return atof(a); 13 } 14 else 15 { 16 if(a[0]==‘+‘) 17 { 18 return f()+f(); 19 } 20 else if(a[0]==‘-‘) 21 { 22 return f()-f(); 23 } 24 else if(a[0]==‘*‘) 25 { 26 return f()*f(); 27 } 28 else if(a[0]==‘/‘) 29 { 30 return f()/f(); 31 } 32 } 33 } 34 int main() 35 { 36 printf("%f\n",f()); 37 return 0; 38 }
原文:http://www.cnblogs.com/zwfymqz/p/6530613.html