题解 |分段计数
衡量人体胖瘦程度
http://www.nowcoder.com/practice/4d604603fae94a26b59b7bc18f363bc0
#include<stdio.h>
int main()
{
int a, b;
float BIM;
while (~scanf("%d%d", &a, &b))
{//为什么这个计算走不过去:1.是不是数据类型的问题
//BIM = a/(b/100)/(b/100);失败写法
//BIM=a/((b/100)*(b/100));
BIM = a / (b / 100.0 * b / 100.0);//这种写法没加点之前也过不了,试点的问题
if (BIM < 18.5) //可能结果是小数,结果丢失了
printf("Underweight\n");
if (BIM >= 18.5&&BIM <= 23.9)
printf("Normal\n");
if (BIM > 23.9&&BIM <= 27.9)
printf("Overweight\n");
if (BIM > 27.9)
printf("Obese\n");
}
return 0;
}
int main()
{
int a, b;
float BIM;
while (~scanf("%d%d", &a, &b))
{//为什么这个计算走不过去:1.是不是数据类型的问题
//BIM = a/(b/100)/(b/100);失败写法
//BIM=a/((b/100)*(b/100));
BIM = a / (b / 100.0 * b / 100.0);//这种写法没加点之前也过不了,试点的问题
if (BIM < 18.5) //可能结果是小数,结果丢失了
printf("Underweight\n");
if (BIM >= 18.5&&BIM <= 23.9)
printf("Normal\n");
if (BIM > 23.9&&BIM <= 27.9)
printf("Overweight\n");
if (BIM > 27.9)
printf("Obese\n");
}
return 0;
}