其他分享
首页 > 其他分享> > 1198:逆波兰表达式

1198:逆波兰表达式

作者:互联网

逆波兰表达式

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 using namespace std;
 5 
 6 const int N=55;
 7 char a[N];
 8 double antiPoland(){
 9     scanf("%s",a);
10     if(a[0]=='+')
11         return antiPoland()+antiPoland();
12     if(a[0]=='-')
13         return antiPoland()-antiPoland();
14     if(a[0]=='*')
15         return antiPoland()*antiPoland();
16     if(a[0]=='/')
17         return antiPoland()/antiPoland();
18     return atof(a);
19 }
20 int main(){
21     printf("%f\n",antiPoland());
22     return 0;
23 }

 

 额外收获:

标签:1198,return,数组,字符,int,波兰,antiPoland,include,表达式
来源: https://www.cnblogs.com/sxrekord/p/reverse_polish_notation.html