问题:
解答:
#include <iostream>
using namespace std;
const int FOOT_TO_INCH =12;
const double INCH_TO_MI = 0.0254;
const float KG_TO_POUND = 2.2;
int main()
{
int inch = 0;
int foot = 0;
int inchs = 0;
double mi = 0;
int pound = 0;
double kg = 0;
double BMI = 0;
cout << "请输入您的身高几尺几寸:";
cin >> foot>>inch;
inchs = foot * FOOT_TO_INCH+inch;
mi = inchs * INCH_TO_MI;
cout << "请输入您的体重(单位为磅):";
cin >> pound;
kg = pound / KG_TO_POUND;
BMI = kg/(mi*mi);
cout << "您的身高为" << mi << "米" << endl;
cout << "您的体重为" << kg << "kg" << endl;
cout << "您的BMI为:" << BMI << endl;
return 0;
}
运行结果:
结果是对的哦.
吐槽这作者老是搞单位换算
2024年8月23日19:34:13