您的位置:首页 > 编程语言 > C语言/C++

第2周项目2-就拿胖子说事

2016-03-09 21:36 337 查看
/*

*Copyright(c)2015,烟台大学计算机学院

*All right reserved。

*文件名称:0308c++.cpp

*作    者:汤善晔

*完成日期:2015年3月8日

*版 本 号:v1.0

*问题描述:成年男性的标准体重公式为:标准体重(kg)=身高(cm)-100,超标准体重20%为超重,

*          比标准体重轻20%为超轻。请编写c++程序,输入身高和体重,计算出并输出标准体重,输出体重状态。

*输入描述:两个整数,分别代表身高和体重

*程序输出:一个整数,一句话,代表标准身高和体重状态

*/

#include <iostream>

using namespace std;

int main()

{

    int stdweight,height,weight;

    float low,high;

    cout<<"请输入身高:"<<endl;

    cin>>height;

    cout<<"请输入体重:"<<endl;

    cin>>weight;

    stdweight=height-100;

    low=stdweight*0.8;

    high=stdweight*1.2;

        cout<<"标准体重为:"<<stdweight<<endl;

    if(weight>high)

    {

        cout<<"超重"<<endl;

    }

    else if(weight<low)

    {

        cout<<"超轻"<<endl;

    }

    else

        cout<<"正常"<<endl;

    return 0;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c语言