main()
{
int tall,weight,normal,fat,thin;
printf("please input tall and weight:");
scanf("%f%f",&tall,&weight);
normal==tall-110;
if(normal-5<=weight<=normal+5)
printf("%s\n","normal");
else if(weight>normal+5)
printf("%s\n","fat");
else if(weight<normal-5)
printf("%s\n","thin");
}
这为什么错???
答案:5 悬赏:0 手机版
解决时间 2021-05-05 21:42
- 提问者网友:趣果有间
- 2021-05-05 04:24
最佳答案
- 五星知识达人网友:神的生死簿
- 2021-05-05 05:42
#include <stdio.h>
main()
{
int tall,weight,normal,fat,thin;
printf("please input tall and weight:");
scanf("%d%d",&tall,&weight); // int要用%d
normal==tall-110;
if(normal-5<=weight && weight<=normal+5)
printf("%s\n","normal");
else if(weight>normal+5)
printf("%s\n","fat");
else if(weight<normal-5)
printf("%s\n","thin");
}
main()
{
int tall,weight,normal,fat,thin;
printf("please input tall and weight:");
scanf("%d%d",&tall,&weight); // int要用%d
normal==tall-110;
if(normal-5<=weight && weight<=normal+5)
printf("%s\n","normal");
else if(weight>normal+5)
printf("%s\n","fat");
else if(weight<normal-5)
printf("%s\n","thin");
}
全部回答
- 1楼网友:鱼忧
- 2021-05-05 09:13
#include<stdio.h>
main()
{
int tall,weight,norm;
printf("please input tall and weight:");
scanf("%d%d",&tall,&weight);
norm=tall-110;
if((norm-5)<=weight&&weight<=(norm+5))
printf("normal\n");
else if(weight>norm+5)
printf("fat\n");
else if(weight<norm-5)
printf("thin\n");
}
- 2楼网友:渊鱼
- 2021-05-05 07:50
这是修改后的程序,在DEV-C++编译器上可以正常运行
main() { int tall,weight,normal,fat,thin; printf("please input tall and weight:"); scanf("%d,%d",&tall,&weight); normal=tall-110; if(normal-5<=weight&&weight<=normal+5) printf("%s\n","normal"); else if(weight>normal+5) printf("%s\n","fat"); else if(weight<normal-5) printf("%s\n","thin"); }
- 3楼网友:老鼠爱大米
- 2021-05-05 07:28
normal-5<=weight<=normal+5
这个地方不能这样写,C语言中a<b<c只能通过a<b&&b<c方式写。
原因:
如果写成a<b<c,由于两个<号优先级相同,因此先计算a<b,得到一个结果(真为1,假为0),然后再把这个结果与c比,造成出错。
- 4楼网友:怀裏藏嬌
- 2021-05-05 07:03
normal==tall-110;不能用双=号,而且normal-5<=weight<=normal+5也有误,
normal =tall-110;
normal-5<=weight&&weight<=normal+5;
好久没用c了,现在在学java,大体一样的。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯