#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
struct inform
{char name[50];
char sex;
int heigh;
int weight;
};
int main()
{
double iweight,i;
inform person;
cout<<"请输入姓名、性别、身高、体重:";
cin>>person.name>>person.sex>>person.heigh>>person.weight;
if(person.sex=='m')
{
iweight=(person.heigh-80)*0.7;
if(person.weight>iweight)
i=person.weight-iweight;
else
i=iweight-person.weight;
if((i/iweight)<=0.1)
cout<<person.name<<"先生"<<"你的体重在正常范围哦~"<<endl;
else if((i/iweight)>0.1&&(i/iweight)<=0.2)
cout<<person.name<<"先生"<<"你他妈超重了啊"<<endl;
else
cout<<person.name<<"死肥仔,赶紧去减肥!!"<<endl;
}
if(person.sex=='f')
{
iweight=(person.heigh-70)*0.6;
if(person.weight>iweight)
i=person.weight-iweight;
else
i=iweight-person.weight;
if((i/iweight)<=0.1)
cout<<person.name<<"女士"<<"你的体重在正常范围内哦~"<<endl;
else if((i/iweight)>0.1&&(i/iweight)<=0.2)
cout<<person.name<<"女士"<<"你有些超重啊~抓紧时间锻炼!"<<endl;
else
cout<<person.name<<"女士"<<"超重了不要紧,多锻炼,加油!"<<endl;
}
return 0;
}
输出结果: