#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> char c1[101],c2[101],c3[101]; float a[101]; int main(){ int i,j,k,m,n; int top=0,v=-1,u=0; gets(c1); k=strlen(c1); for(i=0;i<k;i++){ switch(c1[i]){ case '(':c2[++top]=c1[i];break; case '+': case '-':while(top>0 && c2[top]!='('){ c3[++v]=c2[top]; c3[++v]=' '; top--; } c2[++top]=c1[i]; break; case '*': case '/':while(top>0 && c2[top]!='(' && c2[top]!='+' && c2[top]!='-'){ c3[++v]=c2[top]; c3[++v]=' '; top--; } c2[++top]=c1[i]; break; case ')':while(c2[top]!='('){ c3[++v]=c2[top]; c3[++v]=' '; top--; } top--; break; default: c3[++v]=c1[i]; if(c1[i+1]>'9' || c1[i+1]<'0') c3[++v]=' '; break; } } while(top>0 && c2[top]!='('){ c3[++v]=c2[top]; c3[++v]=' '; top--; } puts(c3); top=0; float sum; k=strlen(c3); for(i=0;i<k;i++){ if(c3[i]==' '); else if(c3[i]=='+'){sum=a[top-1]+a[top];a[--top]=sum;} else if(c3[i]=='-'){sum=a[top-1]-a[top];a[--top]=sum;} else if(c3[i]=='*'){sum=a[top-1]*a[top];a[--top]=sum;} else if(c3[i]=='/'){sum=a[top-1]/a[top];a[--top]=sum;} else{ int m=0; while(c3[i]>='0' && c3[i]<='9'){ m=10*m+c3[i]-'0'; i++; } a[++top]=m; } } printf("%.8f ",a[top]); return 0; }