九度1019 简单计算器
来源:互联网 发布:java图片压缩开源框架 编辑:程序博客网 时间:2024/05/16 05:02
#include<algorithm>#include<cstdio>#include<iostream>#include<string>#include<cstring>#include<vector>#include<set>#include<map>#include<queue>#include<stack>#include<climits>#define eps 1e-9#define ll long longusing namespace std;int op[300];int main(){double x,y;stack<double>numb;stack<char>exp;op['-'] = op['+'] = 2;op['*'] = op['/'] = 1;while(cin>>x){while(!numb.empty())numb.pop();while(!exp.empty())exp.pop();numb.push(x);char c = getchar();if(c == '\n')break;c = getchar();exp.push(c);getchar();while(cin>>x){numb.push(x);c = getchar();if(c == '\n')break;c = getchar();while(!exp.empty()&&op[c]>=op[exp.top()]){char cc = exp.top();x = numb.top();numb.pop();y = numb.top();numb.pop();if(cc == '+')numb.push(y+x);if(cc == '-')numb.push(y-x);if(cc == '*')numb.push(y*x);if(cc == '/')numb.push(y/x);exp.pop();}exp.push(c);getchar();}while(!exp.empty()){char cc = exp.top();x = numb.top();numb.pop();y = numb.top();numb.pop();if(cc == '+')numb.push(y+x);if(cc == '-')numb.push(y-x);if(cc == '*')numb.push(y*x);if(cc == '/')numb.push(y/x);exp.pop();}if(numb.size()!=1)while(1);printf("%.2lf\n",numb.top());}return 0;}
0 0
- 九度1019 简单计算器
- 九度[1019]-简单计算器
- 九度1019:简单计算器 acmclub1918:简单计算器 HDU:1237
- 九度OJ 1019 简单计算器
- 九度oj 题目1019:简单计算器
- 九度oj-1019:简单计算器
- 九度题目1019:简单计算器
- 九度OJ-题目1019:简单计算器
- 九度oj-1019-简单计算器
- 九度OJ 1019:简单计算器
- 九度OJ-1019-简单计算器
- 九度OJ 题目1019:简单计算器
- 九度OJ-1019简单计算器
- <九度 OJ>题目1019:简单计算器
- 九度OJ 题目1019:简单计算器
- 九度OJ 1019 简单计算器
- 【九度】题目1019:简单计算器
- 【九度oj】1019简单计算器
- 最新版SDWebImage的使用
- [转]【Android】 JNI入门 - NDK从入门到精通
- Data truncated for column 'id' at row 1
- 存储IO性能太差,导致数据库hang住
- 鸟哥linux私房菜笔记(第一部分 Linux的规划与安装)
- 九度1019 简单计算器
- 不协调的世界(3)-高速公路
- Solr开发文档
- php simple dom html 解析乱码
- 不知不觉,我也成为入门弟子
- uva 10817 - Headmaster's Headache
- FTP协议速记
- N个线程顺序输出,循环M遍
- Win7下安装CentOS双系统说明