HDU 1170Balloon Comes!
来源:互联网 发布:电脑淘宝网官方下载 编辑:程序博客网 时间:2024/06/10 10:20
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注意输入字符的时候之前加getchar().#include<stdio.h>int main(){int t,i,a,b;char c;double n;scanf("%d",&t);while(t--){getchar();scanf("%c %d %d",&c,&a,&b);if(c=='+')printf("%d\n",a+b);else if(c=='-')printf("%d\n",a-b);else if(c=='*')printf("%d\n",a*b);else{if(a%b==0)printf("%d\n",a/b);elseprintf("%.2lf\n",(double)a/b);}}return 0;}
0 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!
- 整数分解(递归)
- vs2010下,出现链接器工具错误 LNK1104“无法打开文件nafxcw.lib”,或者类似的错误
- 边缘检测(6)Log(Laplacianof Gassian )算子
- Ajax学习
- 使用Struts2标签实现文件上传
- HDU 1170Balloon Comes!
- 黑马程序员----函数,数组
- JAVA中的泛型
- 傅里叶变换的物理意义
- LATEX错误「Unknown graphics extension: .eps」
- 随机产生一个mbit为的长整数
- ASP.NET-FineUI开发实践-1
- RSA加密算法(未完成)
- iOS UITableView(UIScrollView)滑动到底部的判断