HDU 1170 Balloon Comes!
来源:互联网 发布:mac怎么打开doc文件 编辑:程序博客网 时间:2024/06/06 00:17
Balloon Comes!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17032 Accepted Submission(s): 6226
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!
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<T<1000) which is the number of test cases. T test cases follow. Each test case contains a char C (+,-,*, /) and two integers A and B(0<A,B<10000).Of course, we all know that A and B are operands and C is an operator.
Output
For each case, print the operation result. The result should be rounded to 2 decimal places If and only if it is not an integer.
Sample Input
4+ 1 2- 1 2* 1 2/ 1 2
Sample Output
3-120.50
Author
lcy
C表示运算 A,B为操作数 求输出的结果..如果是整数直接输出,浮点数输出两位小数
#include<iostream>#include<cstdio>using namespace std;int main(){ int a,b; int n; char c; while(cin>>n) { while(n--) { cin>>c>>a>>b; switch(c) { case'+':cout<<a+b<<endl;break; case'-':cout<<a-b<<endl;break; case'*':cout<<a*b<<endl;break; case'/':if(a%b==0) cout<<a/b<<endl; else printf("%.2f\n",1.0*a/b);break; } } } return 0;}
- HDU 1170 Balloon Comes!
- HDU 1170 ( Balloon Comes! )
- HDU 1170 Balloon Comes!
- HDU 1170 Balloon Comes!
- HDU 1170Balloon Comes!
- HDU 1170 Balloon Comes!
- HDU 1170 Balloon Comes!
- hdu 1170 Balloon Comes
- hdu-1170 Balloon Comes!
- HDU 1170 Balloon Comes!
- HDU 1170 Balloon Comes!
- hdu-oj 1170 Balloon Comes!
- hdu 1170 Balloon Comes!(模拟)
- HDU 1170 Balloon Comes!【水题】
- hdu 1170 Balloon Comes! 水的很 !!!!!!!!!
- hdu 1170 Balloon Comes!(水题)
- HDU 1170 Balloon Comes! 简单的四则运算
- 杭电 HDU 1170 Balloon Comes!
- 上拉加载 下拉刷新
- 0欧姆电阻的作用
- Linux socket.h 中 CMSG_ALIGN 宏定义的作用(字节对齐)
- Web前端开发神器Webstorm
- 巧用全程监控知道谁动了你的电脑【乡巴佬】
- HDU 1170 Balloon Comes!
- dd测试硬盘盲点
- Struts1 - 配置 - 说明详细且配合例子,简单易懂
- linux软件包重新编译
- 用户指南:必须掌握的九大Office工作技巧【最新文章】
- Codeforces Round #193 (Div. 2) B. Maximum Absurdity
- zoj 2027 Travelling Fee ( 两种解法 1.SPFA 2.floyd()+dp )
- hdu1069 Monkey and Banana
- C++ vector容器类型