CPP9. 判断身材状态
描述
体重指数(BMI)是世界卫生组织(WHO)推荐国际统一使用的肥胖分型标准,即BMI=体重/身高2(kg/m2)。小于 18.5 属于"偏瘦",大于等于 18.5 小于 20.9 属于"苗条",大于等于 20.9 小于等于 24.9 属于"适中",超过 24.9 属于"偏胖"。下面由你来编写一段逻辑,输入用户的身高和体重,计算出对应的体重指数,并返回他们的身材状态。输入描述
用户的身高(m)和用户的体重(kg)输出描述
体重指数对应的身材状态:偏瘦,苗条,适中,偏胖。示例1
输入:
62.5 1.75
输出:
苗条
C++ 解法, 执行用时: 2ms, 内存消耗: 308KB, 提交时间: 2022-04-23
#include <iostream> using namespace std; int main() { double weight; double height; cin >> weight; cin >> height; // write your code here...... double bmi = weight / (height*height); if(bmi < 18.5){ cout << "偏瘦" << endl; } else if( bmi >= 18.5 && bmi < 20.9){ cout << "苗条" << endl; } else if( bmi >= 20.9 && bmi <= 24.9){ cout << "适中" << endl; } else{ cout << "偏胖" << endl; } return 0; }
C++ 解法, 执行用时: 2ms, 内存消耗: 324KB, 提交时间: 2022-01-01
#include <iostream> using namespace std; int main() { double weight; double height; cin >> weight; cin >> height; double bmi=weight/height/height; if(bmi<18.5) cout<<"偏瘦"<<endl; else if(bmi>=18.5&&bmi<20.9) cout<<"苗条"<<endl; else if(bmi>=20.9&&bmi<=24.9) cout<<"适中"<<endl; else cout<<"偏胖"<<endl; return 0; }
C++ 解法, 执行用时: 2ms, 内存消耗: 384KB, 提交时间: 2021-11-29
#include <iostream> using namespace std; int main() { double weight; double height; cin >> weight; cin >> height; // write your code here...... double b; b=weight/(height*height); if(b<18.5) cout<<"偏瘦"; else if(b<20.9) cout<<"苗条"; else if(b<=24.9) cout<<"适中"; else cout<<"偏胖"; return 0; }
C++ 解法, 执行用时: 2ms, 内存消耗: 384KB, 提交时间: 2021-11-22
#include <iostream> using namespace std; int main() { double weight; double height; cin >> weight; cin >> height; // write your code here...... double BMI; BMI=weight/(height*height); if(BMI<18.5) { printf("偏瘦"); } else if(BMI>=18.5&&BMI<20.9) { printf("苗条"); } else if(BMI>=20.9&&BMI<24.9) { printf("适中"); } else if(BMI>=24.9) { printf("偏胖"); } return 0; }
C++ 解法, 执行用时: 2ms, 内存消耗: 388KB, 提交时间: 2022-05-12
#include <iostream> using namespace std; int main() { double weight; double height; cin >> weight; cin >> height; // write your code here...... double BMI; BMI=(weight)/(height*height); if(BMI>=0&&BMI<18.5) { cout<<"偏瘦"; } else if(BMI<20.9) { cout<<"苗条"; } else if(BMI<=24.9) { cout<<"适中"; } else{ cout<<"偏胖"; } return 0; }