项目2 胖瘦问题改进

#include <iostream>
using namespace std;
struct Tizhong
{
    char name;
    char sex;//x为女性y为男性
    double height;
    double weight;
};
int main()
{
    Tizhong t;
    cout<<"请输入姓名,性别(x.y),身高(cm),体重(kg)"<<endl;
    cin>>t.name>>t.sex>>t.height>>t.weight;
    double biao;
    if(t.sex=='y'||t.sex=='Y')
        biao=(t.height-80)*0.7;
    if(t.sex=='x'||t.sex=='X')
        biao=(t.height-70)*0.6;
    if(t.weight<biao*1.2)
    {
        cout<<"您的体重肥胖,oh 可要注意了";
    }
    else if(biao*1.1<t.weight&&t.weight<biao*1.2)
    {
        cout<<"您的体重过重,要合理饮食";
    }
    else if(biao*0.9<t.weight&&t.weight<1.1)
    {
        cout<<"您的体重正常,请继续保持";
    }
    else if(biao*0.8<t.weight&&t.weight<biao*0.9)
    {
        cout<<"您的体重过轻,要合理饮食";
    }
    else
    {
        cout<<"您的体重体重不足,oh 要多吃饭啊";
    }
    return 0;
}


运行结果:

心得体会:本来上次看到其他同学的,挺简单的,今天发现上次错了.

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值