/*
* Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 作 者:申玉迪
* 完成日期:2014 年 2 月 26 日
* 版 本 号:v1.0
* 问题描述: 用结构体测健康状况
*/
#include <iostream>
#include <string.h>
using namespace std;
struct People
{
char name[8];
char sex[4];
double hign;
double weight;
}p;
void puanduan()
{
double t,b;//t表示“标准体重”,b表示“超重了百分之多少”
if(strcmp(p.sex,"男")==0)
{
t=(p.hign-80)*0.7;
}
else
{
t=(p.hign-70)*0.6;
}
if(p.weight>=0.9*t&&p.weight<=1.1*t)
{
cout<<"您的体重正常,请继续保持!"<<endl;
}
else if(p.weight>1.1*t&&p.weight<=1.2*t)
{
b=((p.weight-t)/t)*100;
cout<<"您以超重"<<b<<"%,请做些运动,拥有一个健康的身体。"<<endl;
}
else if(p.weight>1.2*t)
{
b=((p.weight-t)/t)*100;
cout<<"您超重"<<b<<"%,以到达肥胖的状态,建议您控制饮食,多做一些运动,拥有一个健康的身体。"<<endl;
}
else if(p.weight<0.9*t&&p.weight>=0.8*t)
{
cout<<"您的体重过轻,建议您多吃一些饭菜,拥有一个健康的身体。"<<endl;
}
else if(p.weight<0.8*t)
{
cout<<"您的体重不足,建议您有规律的吃饭,拥有一个健康的身体。"<<endl;
}
}
int main()
{
cin>>p.name>>p.sex>>p.hign>>p.weight;
puanduan();
return 0;
}
原来做过,感觉还可以