/*
*Copyright(c)2014,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:满星辰
*完成日期:2014年 12月 22日
*版本号:v1.0
*/
检测体重的东西。。。。。
#include <iostream>
using namespace std;
struct weightion
{
char name[20];
char sex;
double high;
double weight;
};
int main()
{
double stm,overweight;
weightion person;
cout<<"请输入:姓名;性别(m/f);身高(cm);体重(kg);"<<endl;
cin>>person.name>>person.sex>>person.high>>person.weight;
if(person.sex=='m')
stm=(person.high-80)*0.7;
else
stm=(person.high-70)*0.6;
if(person.weight>stm*0.9&&person.weight<stm*1.1)
cout<<person.name<<"您的体重很正常,请继续保持!"<<endl;
else if(person.weight>stm*0.8&&person.weight<=stm*0.9)
cout<<person.name<<"您的体重过轻哦~"<<endl;
else if(person.weight<stm*1.2&&person.weight>=stm*1.1)
{
overweight=(person.weight-stm)/stm*100;
cout<<person.name<<"您的体重过重哦~,超重"<<overweight<<"%"<<endl;
}
else if(person.weight>=stm*1.2)
{
overweight=(person.weight-stm)/stm*100;
cout<<person.name<<"您太胖了!超重"<<overweight<<"%"<<endl;
}
else if(person.weight<=stm*0.8)
cout<<person.name<<"您太轻了!赶紧增肥吧~"<<endl;
return 0;
}
运行展示: