测体重是否正常的程序

时间:2023-02-14 18:20:46
#include <iostream>
#include <iomanip>
#define MIN_STD 18.5
#define MAX_STD 23.9
#define FAT_STD 30


using namespace std;
int main(int argc, char *argv[])
{
cout<<"请输入你的身高(单位 厘米):";
double Height;
cin>>Height;
Height /= 100;
cout<<"请输入您的体重(单位 斤):";
double Weight;
cin>>Weight;
Weight /= 2;
double Health_Result = Weight / (Height * Height);
//cout<<"健康指数:"<<Health_Result<<endl;
//cout<<"正常的健康指数范围是18.5~23.9"<<endl;
//cout<<"最佳的健康指数范围是18.5~22.9"<<endl;
cout<<endl;
if(Health_Result > FAT_STD)
cout<<"你的体重已超重,属于肥胖级别"<<endl;
else if(Health_Result > MAX_STD)
cout<<"你的体重略有超重,但还不属于肥胖级别"<<endl;
else if(Health_Result < MIN_STD)
cout<<"你的体重偏瘦"<<endl;
else
cout<<"恭喜,你的体重正常"<<endl;

cout<<"按照你的身高"<<Height*100<<"厘米,推荐的体重范围是";
double Max_Weight = MIN_STD*(Height*Height)*2;
double Min_Weight = MAX_STD*(Height*Height)*2;
cout<<fixed<<setprecision(1)<<Max_Weight<<"斤~";
cout<<fixed<<setprecision(1)<<Min_Weight<<"斤"<<endl;

cout<<endl;
system("pause");
return 0;
}

可执行文件下载见我的资源 http://download.csdn.net/detail/syrchina/4515941