hdoj-1070-Balloon Comes!
2016-04-14 20:43
260 查看
Problem Description
The contest starts now! How excited it is to see balloons floating around. You, one of the best programmers in HDU, can get a very beautiful balloon if only you have solved the very very very… easy problem.
Give you an operator (+,-,*, / –denoting addition, subtraction, multiplication, division respectively) and two positive integers, your task is to output the result.
Is it very easy?
Come on, guy! PLMM will send you a beautiful Balloon right now!
Good Luck!
Input
Input contains multiple test cases. The first line of the input is a single integer T (0
The contest starts now! How excited it is to see balloons floating around. You, one of the best programmers in HDU, can get a very beautiful balloon if only you have solved the very very very… easy problem.
Give you an operator (+,-,*, / –denoting addition, subtraction, multiplication, division respectively) and two positive integers, your task is to output the result.
Is it very easy?
Come on, guy! PLMM will send you a beautiful Balloon right now!
Good Luck!
Input
Input contains multiple test cases. The first line of the input is a single integer T (0
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { getchar(); char c; int a,b; scanf("%c",&c); scanf("%d%d",&a,&b); if(c=='+') { printf("%d\n",a+b); } else if(c=='-') { printf("%d\n",a-b); } else if(c=='/') { if(a%b==0) printf("%d\n",a/b); else { double n=double(a)/b; printf("%.2lf\n",n); } } else if(c=='*')printf("%d\n",a*b); } return 0; }
相关文章推荐
- LeetCode 145. Binary Tree Postorder Traversal
- 走向视网膜(Retina)的Web时代
- 复利计算升级
- LeetCode - Binary Tree Level Order Traversal
- Android实现图片压缩并且不失真
- 谷歌发布联机版人工智能系统 TensorFlow
- HDU 5247 找连续数(暴力)
- epoll网络编程实例
- C++标准库和标准模板库
- 第三周项目4-辨数字
- 在VS中向命令行添加参数的方法
- 创建和导出SVG的技巧(转载)
- ubuntu上用python安装扩展包遇到的一些问题
- UIImageView圆角,自适应图片宽高比例,图片拉伸,缩放比例和图片缩微图
- ListView这样用
- 软考中高项学员:2016年4月11日作业
- 2016/4/14
- Autofac创建实例的方法总结
- 【LeetCode】98. Validate Binary Search Tree 解法,中序遍历,搜索二叉树合法性
- Redis的spring整合(六)