hdu_1170 Balloon Comes!(简单题)
2014-01-06 21:57
239 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1170
分析: 注意除法时,整除的话就不需要输出小数点后两位了!!
代码:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cstring>
#include <algorithm>
#include <stdlib.h>
#include <map>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);
int main()
{
int t,a,b;
char c;
scanf("%d",&t);
while(t--){
cin>>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) printf("%.2f\n",1.0*a/b);
else printf("%d\n",a/b);
}
}
return 0;
}
分析: 注意除法时,整除的话就不需要输出小数点后两位了!!
代码:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cstring>
#include <algorithm>
#include <stdlib.h>
#include <map>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);
int main()
{
int t,a,b;
char c;
scanf("%d",&t);
while(t--){
cin>>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) printf("%.2f\n",1.0*a/b);
else printf("%d\n",a/b);
}
}
return 0;
}
相关文章推荐
- 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
- hdu1170 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! 水的很 !!!!!!!!!
- hdu 1170 Balloon Comes!(水题)
- 【ACM】hdu_1170_Balloon Comes!_201307261946
- hdu——1170——Balloon Comes!
- HDU 1170 Balloon Comes!(计算表达式)