1 条题解

  • 0
    @ 2026-9-18 21:30:42

    简单if判断

    首先根据题目要求,读入mm与hh

    之后我们推荐计算出BMI指数,也就是建立一个double变量:

    standard=mh2standard = \frac{m}{h^2} standard是水平的意思

    之后按照题意输出:

    比18.5小的,直接输出Underweight

    属于区间[18.5,24)的,直接输出Normal

    都不属于的,

    首先输出BMI指数,再输出Overweight

    代码如下:

    #include<iostream>
    using namespace std;
    int main(){
        double m,h;
        cin>>m>>h;
        double standard=m/h/h;
        if(standard<18.5) cout<<"Underweight";
        else if(standard>=18.5&&standard<24) cout<<"Normal";
        else cout<<"Overweight\n"<<standard;
        return 0;
    }
    

    信息

    ID
    42
    时间
    1000ms
    内存
    256MiB
    难度
    显示难度暂无评定
    标签
    (无)
    递交数
    2
    已通过
    1
    上传者