编号及代码;
/*
*Copyright (c)2014,计算机与控制工程学院
*All rights reserved;
*作者:范星月
*完成日期:2014年12月22日
*版本号:v1.0
*
*问题描述;根据体重标准,判断某人体重情况
*问题输入;输入姓名,性别,身高,体重
*问题输出:输出结果
*/
#include <iostream>
using namespace std;
struct wEight
{
string name ;
char sex;
int height ;
int weight;
};
int main()
{
int strandardm,strandardf;
wEight a;
cout <<"请按顺序输入:姓名:性别:身高:体重:"<<endl;
cin >>a.name >>a.sex>>a.height >>a.weight ;
strandardm=(a.height -80)*0.6;
strandardf=(a.height -70)*0.6;
if (a.sex=='m')
{
if (a.weight >1.2*strandardm)
cout <<"该减减啦"<<endl;
else if (a.weight <=1.2*strandardm&&a.weight >=1.1*strandardm)
cout <<"有点胖,亲"<<endl;
else if (a.weight >0.9*strandardm&&a.weight <1.1*strandardm)
cout <<"体重刚刚好"<<endl;
else if (a.weight >=0.8*strandardm&&a.weight <0.9*strandardm )
cout <<"体重偏轻"<<endl;
else
cout <<"您太轻啦"<<endl;
}
else
{
if (a.weight >1.2*strandardf)
cout <<"该减减啦"<<endl;
else if (a.weight <=1.2*strandardf&&a.weight >=1.1*strandardf)
cout <<"有点胖,亲"<<endl;
else if (a.weight >0.9*strandardf&&a.weight <1.1*strandardf)
cout <<"体重刚刚好"<<endl;
else if (a.weight >=0.8*strandardf&&a.weight <0.9*strandardf)
cout <<"体重偏轻"<<endl;
else
cout <<"您太轻啦"<<endl;
}
return 0;
}
运行结果: