第十七周项目3胖子伤不起

/*
 *Copyright(c)2014,烟台大学计算机学院
 *All rights reserved.
 *文件名称:test.cpp
 *作者:曾晓
 *完成日期:2014年 12月 18日
 *版本号:v1.0
 */
#include <iostream>
#include <cstdio>
using namespace std;
struct Person
{
    char name[20];
    char sex;
    int height;
    double weight;
};
int main()
{
    Person  person;
    double std_weight,over;
    cout<<"请输入您的姓名、性别、身高和体重:"<<endl;
    cin>>person.name>>person.sex>>person.height>>person.weight;
    if(person.sex=='M')
    std_weight=(person.height-80)*0.7;
    else if(person.sex=='F')
    std_weight=(person.height-70)*0.6;
    if(person.weight>=std_weight*0.9 && person.weight<=std_weight*1.1)
        cout<<"您的体重正常哦不用早起跑步了嘻嘻嘻"<<endl;
    else if(person.weight>std_weight*1.1 && person.weight<=std_weight*1.2)
        cout<<"您的体重过重哦看来要早起了好忧桑"<<endl;
        else if(person.weight>std_weight*0.8 && person.weight<std_weight*0.9)
            cout<<"您的体重过轻以后不用早起跑步了!"<<endl;
    else if(person.weight>std_weight*1.2)
        cout<<"您原来是个胖子!"<<endl;
    else if(person.weight<std_weight*0.8)
        cout<<"您体重不足得多吃点了!"<<endl;
     over=(person.weight/std_weight)*100;
     cout<<over<<"%"<<endl;
    return 0;
}


运行结果:

编了很久终于写出来了
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值