#include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <stack> #include <string> using namespace std; int prio(char c) { int p; if (c == '+')p= 1; else if (c == '-')p= 1; else if (c == '*')p= 2; else if (c == '/')p= 2; return p; } float com(float f1, float f2, char c) { float ans; if (c == '+')ans = f1+f2; else if (c == '-')ans= f1 - f2; else if (c == '*')ans= f1 * f2; else if (c == '/')ans= f1 / f2; return ans; } int main() { string s; while (getline(cin, s)) { if (s == "0")break; stack<char>sign; stack<float>num; int n = 0; // cout<<"s = "<<s<<endl; for (int i = 0; i < s.size(); i++) { if (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/') { if (sign.empty())sign.push(s[i]); else { while(!sign.empty()&&prio(sign.top()) >= prio(s[i])) { char c = sign.top(); // sign.push(s[i]); float n1 = num.top(); num.pop(); float n2 = num.top(); num.pop(); float ans = com(n2, n1, c); num.push(ans); sign.pop(); } sign.push(s[i]); } } else if (s[i] >= '0' && s[i] <= '9') { n = n * 10 + (s[i] - '0'); } else { // cout<<"n = "<<n<<endl; if(s[i-1]>= '0' && s[i-1] <= '9')num.push(n); n = 0; } } num.push(n); // cout<<n<<endl; while (!sign.empty()) { char c = sign.top(); sign.pop(); float n1 = num.top(); num.pop(); float n2 = num.top(); num.pop(); float ans = com(n2, n1, c); num.push(ans); } printf("%.2f\n",num.top()); } } // 64 位输出请用 printf("%lld")