站点图标 陌路寒暄

她胖吗?

她胖吗?

时间: 1ms        内存:128M

描述:

奚嘉嘉是位爱美的女孩,身高165cm,体重52.5kg,可还是为保持身材错过了好多口福。实际上,保持健康和快乐,无论胖瘦都是美。当然太胖或太瘦可能对健康不利,适当注意即可。我们要为奚嘉嘉这样的爱美女孩设计一个程序,提供身体、体重,给出建议。女性的标准体重是:身高(厘米)-100= 标准体重(公斤),超过标准体重20%以上者为肥胖,低于标准体重20%的为偏瘦,在肥胖与偏瘦之间为正常。

输入:

身高(cm)与体重(kg)值,身高整数,体重是小数

输出:

肥胖时输出high,正常时输出normal,偏瘦要输出low。(注意全用小写)

示例输入:

165 52.5

示例输出:

normal

提示:

参考答案(内存最优[0]):

#include<stdio.h>
int main()
{
    int height,st;0.8
    float weight;
    scanf("%d %f",&height,&weight);
    st=height-100;
    if(weight/st>1.2)
        printf("high/n");
    else if((weight/st<0.8))
        printf("low/n");
    else
        printf("normal/n");
    return 0;
}

参考答案(时间最优[0]):

#include <iostream>

using namespace std;

int main()
{
    int high ;
    double tizhong,a,b;
    cin>>high>>tizhong;
    a=(high-100);
    b=(tizhong-a)/a;
    if(b>0.2)
    cout<<"high";
    else
    {
        if(b<-0.2)
        {
            cout<<"low";
        }
        else
        cout<<"normal";
    }
    return 0;
}

题目和答案均来自于互联网,仅供参考,如有问题请联系管理员修改或删除。

退出移动版