hdu1237

/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

double n;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	while(scanf("%lf", &n) == 1){
		char c;
		c = getchar();
		stack<double>st;
		st.push(n);
		if(c == '\n' && n == 0){
			break;
		}
		c = getchar();
		while(scanf("%lf", &n) == 1){
			if(c == '*'){
				double u = st.top();
				st.pop();
				st.push(u * n);
			}else if(c == '/'){
				double u = st.top();
				st.pop();
				st.push(u / n);
			}else if(c == '-'){
				st.push(-n);
			}else{
				st.push(n);
			}
			if(getchar() == '\n') break;
			c = getchar();
		}
		double ans = 0;
		while(st.size()){
			ans += st.top();
			st.pop();
		}
		printf("%.2lf\n", ans);
	}

	return 0;
}
/**/

 

全部评论

相关推荐

04-10 11:56
如皋中学 Java
高斯林的信徒:双c9能简历挂的?
点赞 评论 收藏
分享
05-26 10:24
门头沟学院 Java
qq乃乃好喝到咩噗茶:其实是对的,线上面试容易被人当野怪刷了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务