编译正常,运行结果一直是正常,不知道问题出在哪儿,可以帮忙看看吗
#include<stdio.h>
int main()
{
int age;
char gender;
float BMI,height,weight;
printf("please input your gender(M or F),age,height(m) and weight(kg): \n");//M为男,F为女
scanf("%c %d %f %f",&gender,&age,&height,&weight);
BMI=weight/(height*height);
if(age>=18)
{
if(gender=='M')
{
if(BMI<18.5)
printf("your weight:偏瘦");
else if(18.5<BMI<24)
printf("your weight:正常");
else if(24<=BMI<28)
printf("your weight:偏胖");
else
printf("your weight:非常肥胖");
}
else
{
if(BMI<18)
printf("your weight:偏瘦");
else if(18<=BMI<23.5)
printf("your weight:正常");
else if(23.5<=BMI<27)
printf("your weight:偏胖");
else
printf("your weight:非常肥胖");
}
}
else if(10<=age<18)
{
if(gender=='M')
{
if(BMI<17)
printf("your weight:偏瘦");
else if(17<=BMI<23.5)
printf("your weight:正常");
else if(23.5<=BMI<27)
printf("your weight:偏胖");
else
printf("your weight:非常肥胖");
}
else
{
if(BMI<16.5)
printf("your weight:偏瘦");
else if(16.5<=BMI<23)
printf("your weight:正常");
else if(23<=BMI<26.5)
printf("your weight:偏胖");
else
printf("your weight:非常肥胖");
}
}
else if(3<=age<10)
{
if(gender=='M')
{
if(BMI<19)
printf("your weight:偏瘦");
else if(19<=BMI<24.5)
printf("your weight:正常");
else if(24.5<=BMI<29)
printf("your weight:偏胖");
else
printf("your weight:非常肥胖");
}
else
{
if(BMI<18.5)
printf("your weight:偏瘦");
else if(18.5<=BMI<24)
printf("your weight:正常");
else if(24<=BMI<28.5)
printf("your weight:偏胖");
else
printf("your weight:非常肥胖");
}
}
else
{
if(gender=='M')
{
if(BMI<19.5)
printf("your weight:偏瘦");
else if(19.5<=BMI<25)
printf("your weight:正常");
else if(25<=BMI<28.5)
printf("your weight:偏胖");
else
printf("your weight:非常肥胖");
}
else
{
if(BMI<19)
printf("your weight:偏瘦");
else if(19<=BMI<25)
printf("your weight:正常");
else if(25<=BMI<28.5)
printf("your weight:偏胖");
else
printf("your weight:非常肥胖");
}
}
return 0;
}