//cww 逆波兰计算器
#include<stack>
#include<cstdio>
#include<iostream>
using namespace std;
stack<double>s;char read(){while (1){printf("Select command and press<Enter>:");char ch; cin>>ch;if (ch=='?'||ch=='='||ch=='+'||ch=='-'||ch=='*'||ch=='/'||ch=='q'||ch=='Q')return ch;puts("Please enter a valid command:");puts("[?]push to stack [=]print top");puts("[+] [-] [*] [/] you know them");puts("[Q]uit =======Bazinga!=======");}
}bool solve(char ch){double x,y;if (ch=='q'||ch=='Q'){puts("Calculation finshed.");return 0;}if (ch=='?'){printf("Enter a real number:");cin>>x; s.push(x);}if (ch=='='){if (s.empty())puts("Stack empty");else printf("%.0lf\n",s.top());}if (ch=='+'||ch=='-'||ch=='*'||ch=='/'){if (s.empty())puts("Stack empty");else{x=s.top(); s.pop();if (s.empty()){puts("Stack has just one entry");s.push(x);}else{y=s.top();s.pop();switch (ch){case'+':s.push(x+y);break;case'-':s.push(x-y);break;case'*':s.push(x*y);break;case'/':s.push(x/y);break;}}}}return 1;
}
//==========cww=2016,2,28=23:27===============
int main(){puts("welcome");while (!s.empty())s.pop();while (solve(read())){}return 0;
}

Polish calculation相关推荐

  1. leetcode - 150. Evaluate Reverse Polish Notation

    前言:记录一下leetcode上的一道题目: 题目网址:https://leetcode.com/problems/evaluate-reverse-polish-notation/descripti ...

  2. flaash-ACC_LSMOOTH2: Cannot continue with smoothing calculation

    2009年6月21日 15:22:22 采用flaash对MOD02HKM数据进行大气校正,在运行中总是出现ACC_LSMOOTH2: Cannot continue with smoothing c ...

  3. leetcode day1 -- Reverse Words in a String Evaluate Reverse Polish Notation Max Points on a Li

    以前从来没做过什么oj,发现做oj和在本地写代码或者纸上写差别还是很大的,觉得今天开始刷oj,特此记录一下. 1.Reverse Words in a String Given an input st ...

  4. Algorithm:C++语言实现之链表相关算法(单链公共结点问题、一般LCA、括号匹配、最长括号匹配、逆波兰表达式Reverse Polish Notation、直方图矩形面积、收集雨水问题)

    Algorithm:C++语言实现之链表相关算法(单链公共结点问题.一般LCA.括号匹配.最长括号匹配.逆波兰表达式Reverse Polish Notation.直方图矩形面积.收集雨水问题) 目录 ...

  5. nextpolish安装_「三代组装」使用Pilon对基因组进行polish

    软件安装 官方提供了编译好的jar包,方便使用 wget https://github.com/broadinstitute/pilon/releases/download/v1.23/pilon-1 ...

  6. Reverse Polish Notation

    http://www.1point3acres.com/bbs/thread-31595-1-1.html 定义一种叫做"Reverse Polish Notation"的表达式: ...

  7. 21.等值线图(Counter Plot)、Contour Demo、Creating a “meshgrid”、Calculation of the Values、等

    21.等值线图(Counter Plot) 21.1.Contour Demo 21.2.Creating a "meshgrid" 21.3.Calculation of the ...

  8. understanding shader mat4 * vec4 calculation​

    为什么80%的码农都做不了架构师?>>>    this blog from: http://stackoverflow.com/questions/13745334/underst ...

  9. SAP Analytics Cloud里基于dimension的calculation

    基于图表创建动态的calculation: calculation类型为Aggregation,操作为计算dimension出现的个数:count dimension 要获取更多Jerry的原创文章, ...

  10. LeetCode-150-Evaluate Reverse Polish Notation

    算法描述: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are ...

最新文章

  1. mysql数据字典生成,在线生成mysql数据字典
  2. 聊聊并发(三)——JAVA线程池的分析和使用
  3. 自动打包+ios+android,使用 python 自动打包 Android 和 iOS
  4. tensorflow随笔-collection收集器
  5. postman模拟post请求的四种请求体
  6. 《关于我的那些面经》——百度后端(附答案)
  7. 正则表达式在NLP的基本应用
  8. mysql中文占两位_mysql 保留两位小数
  9. web前端优化--图片优化
  10. 开源中文分词FudanNLP
  11. 安卓zip解压软件_破解软件之“安卓压缩包zip或rar密码破解(116位数任意破)”...
  12. CMOS图像传感器OV7725数据手册
  13. 小程序跳转页面弹出公众号引导用户关注
  14. 如何使用 R 从 Internet 下载文件
  15. 2020CSP初赛试题答案解析
  16. 运维-系统监控方案:基于Grafana的TDengine零依赖监控解决方案
  17. JQuery 基础 jq选择器 dom操作
  18. 大暑节气海报图片|大暑节气海报文案
  19. 微信图标现在可以换颜色了???
  20. 快速进行OneHot编码——get_dummies()函数

热门文章

  1. DCO-OFDM可见光通信matlab
  2. CImage::Loda 方法加载图片失败,因为vs2013中该方法不支持中文变量
  3. 微软开源 Python 自动化神器 Playwright
  4. 2022 年江苏省职业院校技能大赛(中职) 网络搭建与应用赛项公开赛卷
  5. # C语言使用树设计族谱
  6. V2X方案之OBU介绍
  7. 欧美游戏业者都挣多少钱
  8. 【最新】Blender资产库纹理灯光 预设打光技巧
  9. idea报错cannot access com.*.*
  10. powershell_windows命令行杀进程(pskill)/进程任务管理/服务管理/(查看/关闭/停止/移除windows移除mysql服务)