Balloon Comes!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 26455    Accepted Submission(s): 10055

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<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
-1
2
0.50
 
分析:简单题,只要注意除法的时候,如果能整除则直接输出就行,否则保留两位小数
 #include <iostream>
#include <cstdio>
using namespace std; int main(){
char c;
int t, a, b;
cin >> t;
while(t--){
cin >> c >> a >> b;
if(c == '+')
cout << (a + b) << endl;
else if(c == '-')
cout << (a - b) << endl;
else if(c == '*')
cout << (a * b) << endl;
else if(c == '/'){
if(a % b == )
cout << (a / b) << endl;
else
printf("%.2f\n", (float)a / b);
}
}
return ;
}

hdu 1170 Balloon Comes!的更多相关文章

  1. 杭电1170 Balloon Comes

    Problem Description The contest starts now! How excited it is to see balloons floating around. You, ...

  2. HDU 1170 Shopping Offers 离散+状态压缩+完全背包

    题目链接: http://poj.org/problem?id=1170 Shopping Offers Time Limit: 1000MSMemory Limit: 10000K 问题描述 In ...

  3. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  4. HDU 1004 Let the Balloon Rise【STL<map>】

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  5. hdu 1004 Let the Balloon Rise(字典树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  6. HDU 1004 Let the Balloon Rise(map的使用)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  7. 背包系列练习及总结(hud 2602 && hdu 2844 Coins && hdu 2159 && poj 1170 Shopping Offers && hdu 3092 Least common multiple && poj 1015 Jury Compromise)

    作为一个oier,以及大学acm党背包是必不可少的一部分.好久没做背包类动规了.久违地练习下-.- dd__engi的背包九讲:http://love-oriented.com/pack/ 鸣谢htt ...

  8. Balloon Comes! hdu(小数位数处理)

    Balloon Comes! Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): A ...

  9. hdu 1004 Let the Balloon Rise

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

随机推荐

  1. IMAQ Flatten Image to String VI的参数设置对比

    无压缩 jpeg压缩 无损二元包装 仅JPEG压缩时有效 平化类型(指定字符串中存储什么类型的数据)   None JPEG PACKED BINARY Quality Image Image and ...

  2. oracle 监测数据库是否存在指定字段

    public static bool ExistColumn(string tableName, string columnName, string connStr) { using (OracleC ...

  3. swfupload用法总结

    <script src="${base}/thirdparty/swfupload/swfupload.js" type="text/javascript" ...

  4. hdu 5745 La Vie en rose DP + bitset优化

    http://acm.hdu.edu.cn/showproblem.php?pid=5745 这题好劲爆啊.dp容易想,但是要bitset优化,就想不到了. 先放一个tle的dp.复杂度O(n * m ...

  5. Lua学习笔记(一):搭建开发环境

    Lua是一个小巧高效的解释型脚本语言,可以方便的嵌入到任意的语言中,很多应用程序.游戏使用LUA作为自己的嵌入式脚本语言,以此来实现可配置性.可扩展性.这其中包括魔兽世界.博德之门.愤怒的小鸟.VOC ...

  6. jquery formValidate demo 采用struts 异步方式检验用户名是否存在

    1 login.jsp <%@taglib uri="/struts-tags" prefix="s"%><!DOCTYPE html PUB ...

  7. Unix: How to Install BerkeleyDB From Source

    http://www.masaokitamura.com/2010/07/23/unix-how-to-install-berkeleydb-from-source/ This documentati ...

  8. UVa699 The Falling Leaves

      // UVa699 The Falling Leaves // 题意:给一棵二叉树,每个节点都有一个水平位置:左儿子在它左边1个单位,右儿子在右边1个单位.从左向右输出每个水平位置的所有结点的权值 ...

  9. 【WebForm】Repeater 序列号 在翻页情况下自增

    asp.net Repeater控件分页时,序号列翻页重新从1开始计数问题的解决思路及方法: 一般情况下,使用 <%# Container.ItemIndex + 1% > 给序号列来自增 ...

  10. mac 环境下mysql 不能删除schema问题的解决办法

    首先说明下问题环境,我是在mac机器上安装的mysql+workbench. 在删除一个数据库的时候,出现error dropping database cant rmdir ./test 的问题. ...