#include <iostream>
#include <cmath>
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<<"Please input your height in [m] :";
cin>>human01.high;
cout<<"Please input your Weight in [kg] :";
cin>>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<<"You are in standard value!!!\n";
}
else if(bmi<18.5)
{
do
{
w+=0.5;
bmiTemp=w/pow(b
【C++学习笔记】结构与函数:一个BMI计算小程序
最新推荐文章于 2024-02-02 15:00:41 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)