#include<bits/stdc++.h> using namespace std; //判断字符是否为数字字符 bool isnum(char a) { return a>='0'&&a<='9'; } //判断是否为运算符 bool isyun(char a) { if(a == '+'||a=='-'||a=='*'||a=='/') { return true; } return false; } //比较运算符的优先级 int isbigger(char a,char b) { if(a == '*'||a == '/') { if(b == '+'||b == '-') { return 1; } else { return 0; } } else { if(b == '*'||b == '/') { return -1; } else { return 0; } } } int main() { string str; while(getline(cin,str)) { if(str == "0")break; int len = str.length(); stack<char> s; string output = ""; int i = 0; while(i<len) { int sum = 0; if(isnum(str[i])) { while(str[i] != ' '&&i<len) { sum = sum*10 + str[i]-'0'; i++; } output += to_string(sum) + " "; } else if(isyun(str[i])) { while(!s.empty()&&isbigger(str[i],s.top())<=0) { output += s.top(); output += " "; s.pop(); } s.push(str[i]); i++; } else { i++; } } while(!s.empty()) { output += s.top(); output += " "; s.pop(); } //对后缀表达式进行计算求值 stack<float> st; int l = output.length(); int j = 0; while(j<l) { float sum = 0.00; if(isnum(output[j])) { while(isnum(output[j])&&j<l) { sum = sum*10 + output[j]-'0'; j++; } st.push(sum); } else if(isyun(output[j])) { float b = st.top();st.pop(); float a = st.top();st.pop(); if(output[j] == '+')st.push(a+b); if(output[j] == '-')st.push(a-b); if(output[j] == '*')st.push(a*b); if(output[j] == '/') { if(b == 0) { cout<<"除零错误!"<<endl; return -1; } st.push(a/b); } j++; } else { j++; } } printf("%.2f",st.top()); st.pop(); cout<<endl; } return 0; }