题解 | #判断身材状态#
判断身材状态
https://www.nowcoder.com/practice/6f4afb0f8be64d5eaf65a205b8584888
#include <iostream>
std::string getBodyType(double weight, double height) {
double bmi = weight / (height * height);
if (bmi < 18.5) {
return "偏瘦";
} else if (bmi >= 18.5 && bmi < 20.9) {
return "苗条";
} else if (bmi >= 20.9 && bmi < 24.9) {
return "适中";
} else {
return "偏胖";
}
}
int main() {
double weight, height;
std::cin >> weight;
std::cin >> height;
std::string bodyType = getBodyType(weight, height);
std::cout << bodyType << std::endl;
return 0;
}
传音控股晋升空间 50人发布