第17周项目3 胖子伤不起




/*    
*Copyright (c)2014,烟台大学计算机与控制工程学院    
*All rights reserved.    
*文件名称:rr.cpp    
*作    者  张伟建    
*完成日期:2014年12月17日    
*版 本 号:v1.0    
*    
*问题描述: 结构体问题  
*输入描述:     
*输出描述:     
*/        

#include <iostream>

using namespace std;
struct Person
{
  char name[10];
  char sex;
  int  height;
  double weight;
};
int main()
{
    Person per;
    cout<<"请输入一个人的姓名,性别,身高,体重"<<endl;
    cin>>per.name>>per.sex>>per.height>>per.weight;
    char M,F;
    double w1,w2;

    if(per.sex=='M')
    {
       w1=(per.height-80)*0.7;
       if((per.weight<=w1*1.1)&&(per.weight>=w1*0.9))
       cout<<"您的体重正常";
       else if((per.weight<=w1*1.2)&&(per.weight>=w1*1.1))
       cout<<"您的体重过重";
       else if((per.weight<w1*0.9)&&(per.weight>w1*0.8))
       cout<<"您的体重过轻";
       else if(per.weight<=w1*0.8)
            cout<<"过轻";
       else
        cout<<"过重";
    }
    if(per.sex=='F')
    {
       w2=(per.height-70)*0.6;
       if((per.weight<=w2*1.1)&&(per.weight>=w2*0.9))
       cout<<"您的体重正常";
       else if((per.weight<=w2*1.2)&&(per.weight>=w2*1.1))
       cout<<"您的体重过重";
       else if((per.weight<w2*0.9)&&(per.weight>w2*0.8))
       cout<<"您的体重过轻";
       else if(per.weight<=w2*0.8)
            cout<<"体重不足";
       else
        cout<<"肥胖";
    }

    return 0;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值