这题让我们计算出 BMI 值,随后判断属于哪个等级。
BMI 值计算公式:
。
BMI 范围 | 对应信息 |
大于 25 | Overweight |
介于 18.5 与 25.0 之间 | Normal weight |
小于 18.5 | Underweight |
AC CODE:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
double weight;
double height;
cin>>weight;
cin>>height;
double cnt = height*height;
double BMI = weight/cnt;
string res;
if(BMI<18.5){
res = "Underweight";
}else if(BMI>=18.5&&BMI<=25.0){
res = "Normal weight";
}else if(BMI>25.0){
res = "Overweight";
}
cout<<res<<endl;
return 0;
}