#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
using namespace std;
int main()
{
double n;
while(scanf("%lf",&n)!=EOF)
{
stack<double>q;
q.push(n);
char fuhao;
double shu;
double tmp;
while(getchar()!='\n')
{
scanf("%c %lf",&fuhao,&shu);
if(fuhao=='+')
q.push(shu);
else
{
if(fuhao=='-')
{
q.push(-shu);
}
else
{
if(fuhao=='*')
{
tmp=shu*q.top();
q.pop();
q.push(tmp);
}
else
{
tmp=q.top()/shu;
q.pop();
q.push(tmp);
}
}
}
}
if(q.top()==0&&q.size()==1)
{
break;
}
double ans=0;
while(!q.empty())
{
ans=ans+q.top();
q.pop();
}
printf("%.2lf\n",ans);
}
return 0;
}
H - 简单计算器(stl)
最新推荐文章于 2021-12-13 17:01:13 发布