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

本博客提供了一个简单的程序,用于输入个人的基本信息(如姓名、性别、身高和体重),并根据国际标准来检测和评估体重是否正常,过轻或过重,并给出相应的建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*
 *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;
}

运行展示:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值