/*
烟台大学计算机学院学生
*All rights reserved.
*文件名称:胖子伤不起
*作者:王洪海
*完成日期:2013年3月2日
*版本号:v1.0
*对任务及求解方法的描述部分:胖子伤不起
*我的程序:
*/
#include <iostream>
#include <string>
using namespace std;
struct People
{
string name;
string sex;
double hight;
double weight;
};
People people;
int jdz(int ,int);
int main()
{
int b,c,t;
cout<<"请输入您的姓名、性别、身高、体重:"<<endl;
cout<<endl;
cin>>people.name>>people.sex>>people.hight>>people.weight;
cout<<endl;
if(people.sex=="男")
{
b=(people.hight-80)*0.7;
c=jdz(people.weight,b);
if(c<=b*0.1)
t=1;
else if(c>b*0.1&&c<=b*0.2)
t=2;
else
t=3;
switch (t)
{
case 1:
cout<<"先生,你的身材很棒,很标准!"<<endl;
break;
case 2:
cout<<"先生,你的身材有点瘦弱了,要抓紧增重了!"<<endl;
break;
case 3:
cout<<"先生,要注意喽,你属于超重范围了!!"<<endl;
}
}
if(people.sex=="女")
{
b=(people.hight-70)*0.6;
c=jdz(people.weight,b);
if(c<=b*0.1)
t=1;
else if(c>b*0.1&&c<=b*0.2)
t=2;
else
t=3;
switch (t)
{
case 1:
cout<<"女士,你的身材很棒,很标准!"<<endl;
break;
case 2:
cout<<"女士,你的身材有点瘦弱了,别太骨干喽!"<<endl;
break;
case 3:
cout<<"女士,要注意喽,你属于超重范围了!!"<<endl;
}
}
return 0;
}
int jdz(int x,int y)
{
int z;
z=x-y;
if(z>0)
return z;
else
return -z;
}
运行结果,如下图: