#include <iostream>
using namespace std;
struct Tizhong
{
char name;
char sex;//x为女性y为男性
double height;
double weight;
};
int main()
{
Tizhong t;
cout<<"请输入姓名,性别(x.y),身高(cm),体重(kg)"<<endl;
cin>>t.name>>t.sex>>t.height>>t.weight;
double biao;
if(t.sex=='y'||t.sex=='Y')
biao=(t.height-80)*0.7;
if(t.sex=='x'||t.sex=='X')
biao=(t.height-70)*0.6;
if(t.weight<biao*1.2)
{
cout<<"您的体重肥胖,oh 可要注意了";
}
else if(biao*1.1<t.weight&&t.weight<biao*1.2)
{
cout<<"您的体重过重,要合理饮食";
}
else if(biao*0.9<t.weight&&t.weight<1.1)
{
cout<<"您的体重正常,请继续保持";
}
else if(biao*0.8<t.weight&&t.weight<biao*0.9)
{
cout<<"您的体重过轻,要合理饮食";
}
else
{
cout<<"您的体重体重不足,oh 要多吃饭啊";
}
return 0;
}
运行结果:
心得体会:本来上次看到其他同学的,挺简单的,今天发现上次错了.