您的位置:首页 > 其它

HDU1170

2016-09-28 19:48 120 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1170

除法的输出居然没有考虑整除情况,结果连续wa了三次才发现

#include<iostream>
using namespace std;

int main()
{
int t,a,b;
char c;
scanf("%d",&t);
while(t--)
{
cin>>c>>a>>b;
if(c=='+')  printf("%d",a+b);
if(c=='-') printf("%d",a-b);
if(c=='*') printf("%lld",a*b);
if(c=='/')
{
if(a%b==0) printf("%d",a/b);
else printf("%.2lf",a*1.0/b);
}
printf("\n");
}
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: