C语言基础除法A/B 真的好迷啊
答案:2 悬赏:20 手机版
解决时间 2021-01-07 21:32
- 提问者网友:锁深秋
- 2021-01-07 17:43
C语言基础除法A/B 真的好迷啊
最佳答案
- 五星知识达人网友:街头电车
- 2021-01-07 17:48
#include
#include
int main ()
{
int a,b;
double c;
scanf( "%d%d",&a,&b );
//a>=-100&&a<=100;
//b>=-100&&b<=100;
c=a*1.00/b;
if(b>0)
printf("%d/%d=%.2lf",a,b,c);
if(b<0)
printf("%d/(%d)=%.2lf",a,b,c);
if(b==0)//<=============================
printf("Error");//<=============================
system("pause");
return 0;
}
#include
int main ()
{
int a,b;
double c;
scanf( "%d%d",&a,&b );
//a>=-100&&a<=100;
//b>=-100&&b<=100;
c=a*1.00/b;
if(b>0)
printf("%d/%d=%.2lf",a,b,c);
if(b<0)
printf("%d/(%d)=%.2lf",a,b,c);
if(b==0)//<=============================
printf("Error");//<=============================
system("pause");
return 0;
}
全部回答
- 1楼网友:西风乍起
- 2021-01-07 18:22
判定的符号错了
b==0才对
#include
#include
int main ()
{
int a,b;
double c;
scanf( "%d%d",&a,&b );
a>=-100&&a<=100;
b>=-100&&b<=100;
c=a*1.00/b;
if(b>0)
printf("%d/%d=%.2lf",a,b,c);
if(b<0)
printf("%d/(%d)=%.2lf",a,b,c);
if(b==0)
printf("Error");
system("pause");
return 0;
}
b==0才对
#include
#include
int main ()
{
int a,b;
double c;
scanf( "%d%d",&a,&b );
a>=-100&&a<=100;
b>=-100&&b<=100;
c=a*1.00/b;
if(b>0)
printf("%d/%d=%.2lf",a,b,c);
if(b<0)
printf("%d/(%d)=%.2lf",a,b,c);
if(b==0)
printf("Error");
system("pause");
return 0;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯