#include <iostream> #include <stack> #include <iomanip> using namespace std; stack<char> opetor; stack<double> digit; bool isdigit(char x){ if(x>='0'&&x<='9') return true; else return false; } double getdigit(string x,int& i){ int r=0; while(isdigit(x[i])){ r=r*10+x[i]-'0'; i++; } return double(r); } int priority(char x){ if(x=='#') return 1; else if(x=='$') return 2; else if(x=='+'||x=='-') return 3; else if(x=='*'||x=='/') return 4; else return -1; } double getvalue(double x,double y,char o){ if(o=='+') return x+y; else if(o=='-') return x-y; else if(o=='*') return x*y; else return x/y; } int main() { string x; while(getline(cin,x) && x!="0"){ opetor.push('#'); x=x+'$'; int i=0; while(i<x.length()){ if(x[i]==' ') { i++; } else if(isdigit(x[i])){ digit.push(getdigit(x,i)); } else{ if(priority(x[i])>priority(opetor.top())){ opetor.push(x[i]); i++; } else{ double d2=digit.top(); digit.pop(); double d1=digit.top(); digit.pop(); double r=getvalue(d1,d2,opetor.top()); opetor.pop(); digit.push(r); } } } printf("%.2f",digit.top()); cout<<endl; } }