您的位置:首页 > 其它

第二周上机实践项目——项目2-就拿胖子说事

2016-03-10 08:46 204 查看
/* 
 *Copyright(c) 2016, 烟台大学计算机与控制工程学院 
 *All rights reserved. 
 *文件名称:high and weight.cpp 
 *作    者:郑志金
 *完成日期:2016年3月10日 
 *版本号:v1.0 
 * 
 *问题描述:输入身高和体重,给出标准体重公式,完成下列任务:
                      (1)计算并输出标准体重。
                      (2)计算出标准体重,当超重时,请给出提示。
                      (3)计算出标准体重,当超重时给出提示,不超重时也给出提示。
                      (4)计算出标准体重,输出体重状态(正常/超重/超轻)。

 *输入描述:输入身高和体重
 *输出描述:输出标准体重和体重状态 
 */  
(1)

#include<iostream>

using namespace std;

int main()

{

    int high,weight;

    cout<<"请输入当前身高:";

    cin>>high;

    weight=high-100;

    cout<<"标准体重为:"<<weight<<"kg"<<endl;

        return 0;

}

运行结果:



(2)

            

 #include<iostream>

 using namespace std;

 int main()

{

    int high,weight,weight1;

    cout<<"请输入当前身高:";

    cin>>high;

    cout<<"请输入当前体重:";

    cin>>weight;

    weight1=high-100;

    if(weight>weight1)

        cout<<"超重"<<endl;

        return 0;

}

 运行结果:





 (3)

#include<iostream>

using namespace std;

int main()

{

    int high,weight,weight1;

    cout<<"请输入当前身高:";

    cin>>high;

    cout<<"请输入当前体重:";

    cin>>weight;

    weight1=high-100;

    if(weight>weight1)

        cout<<"超重"<<endl;

    else

        cout<<"不超重"<<endl;

        return 0;

}

运行结果:





(4)

#include<iostream>

using namespace std;

int main()

{

    int high,weight,weight1;

    cout<<"请输入当前身高:";

    cin>>high;

    cout<<"请输入当前体重:";

    cin>>weight;

    weight1=high-100;

    if(weight>weight1)

        cout<<"超重"<<endl;

    if(weight<weight1)

        cout<<"超轻"<<endl;

    if(weight==weight1)

        cout<<"正常"<<endl;

        return 0;

}

 运行结果:







知识点总结:

清楚了发布博文的格式,更加规范了程序。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: