1357.000000
代码:
#include<stdio.h> #include<stdlib.h> double polan(){ char s[10]; scanf("%s",s); switch(s[0]){ case '+':return polan()+polan();break; case '-':return polan()-polan();break; case '*':return polan()*polan();break; case '/':return polan()/polan();break; default:return atof(s);} } int main(){ printf("%f\n",polan()); return 0;}
#include<stdio.h> #include<stdlib.h> char *polan(){ char s[10]; scanf("%s",s); switch(s[0]){ case '+':printf("( "),polan(),printf("+"),polan(),printf(" )");break; case '-':printf("( "),polan(),printf("-"),polan(),printf(" )");break; case '*':printf("( "),polan(),printf("*"),polan(),printf(" )");break; case '/':printf("( "),polan(),printf("/"),polan(),printf(" )");break; default:printf("%s",s);return s;} } int main(){ printf("%s\n",polan()); return 0;}