【C++学習ノート】構造と関数:BMI計算ウィジェット
766 ワード
#include
#include
using namespace std;
struct BMI
{
double high; //unit:m
double weight; //unit:kg
};
double compBMI(BMI b);
void showStandHW(BMI b1,BMI b2);
BMI standBMI(BMI b);
int main()
{
BMI human01;
cout<>human01.high;
cout<>human01.weight;
BMI human=standBMI(human01);
showStandHW(human01,human);
system("pause");
return 0;
}
double compBMI(BMI b)
{
double bmi;
bmi=b.weight/pow(b.high,2);
return bmi;
}
BMI standBMI(BMI b)
{
double bmi;
double bmiTemp;
double w;
BMI stanWeight;
int i;
bmi=b.weight/pow(b.high,2);
w=b.weight;
if (bmi<=23.9&&bmi>=18.5)
{
stanWeight=b;
cout<23.9);
stanWeight.weight=w;
cout<