#include <iostream>
using namespace std;
struct student
{
char name[20];
char sex;
int high;
int weight;
} stu1;
int main()
{
int m,z;
cout << "请输入您的姓名:";
cin>>stu1.name;
cout << "请输入您的性别:";
cin>>stu1.sex;
cout << "请输入您的身高:";
cin>>stu1.high;
cout << "请输入您的体重:";
cin>>stu1.weight;
cout<<stu1.name;
switch(stu1.sex)
{
case 'm':
m=(stu1.high-70)*0.6;
cout<<"MM,";
break;
case 'f':
m=(stu1.high-80)*0.7;
cout<<"GG,";
break;
}
z=(stu1.weight-m)/m;
if((z>=0&&z<=0.1)||(z<=0&&z>=-0.1))
{
cout<<"你的体重正常哟";
}else
if(z>=0.1&&z<=0.2)
{
cout<<"你有点偏胖哦";
}else
if(z>=-0.2&&z<=-0.1)
{
cout<<"你有点瘦哦";
}else
if(z>0.2)
{
cout<<"你超重啦";
}else
{
cout<<"你太轻了,多吃点";
}
return 0;
}
运行结果: