您的位置:首页 > 其它

项目2-就拿胖子说事

2016-03-10 21:04 127 查看
问题及代码:
/*
*copyright (t) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:main.cpp
*作者:郝昱猛
*完成日期:2016年3月10日
*版本号:v1.0
*问题描述:成年男性的标准体重公式为:标准体重(kg)=身高(cm)-100,超标准体重20%为超重,比标准体重轻20%为超轻。请编写c++程序输入身高和体重,完成下面任务。
(1)计算并输出标准体重。
(2)计算出标准体重,当超重时,请给出指示。
(3)计算出标准体重,当超重时给出提示,不超重时也给提示。
(4)计算出标准体重,输出体重状态(正常/超重/超轻)
*输入描述:输入身高。
*程序输出:输出体重状态。
*/
(1)
#include<iostream>
using namespace std;
int main ()
{
double height,weight;
cout <<"请输入您的身高:"<<endl;
cin>>height;
weight=height-100;
cout <<"标准体重:"<<weight<<endl;

return 0;
}
运行结果:(2)
#include<iostream>
using namespace std;
int main()
{
    double weight ,height,biaozhun;
    cout <<"请输入您的体重和身高:"<<endl;
    cin>>weight>>height;
    biaozhun=height-100;
   if(weight>biaozhun*1.2)
    cout <<"超重"<<endl;
    return 0;
}
运行结果:<img src="http://img.blog.csdn.net/20160313214715905?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
<span style="font-family: Arial, Helvetica, sans-serif;">(3)</span>
#include<iostream>
using namespace std;
int main()
{
    double weight ,height,biaozhun;
    cout <<"请输入您的体重身高:"<<endl;
    cin>>weight>>height;
    biaozhun=height-100;
   if(weight>biaozhun*1.2)
    cout <<"超重"<<endl;
   else
    cout<<"您没有超重"<<endl;
    return 0;
}
运行结果:<img src="http://img.blog.csdn.net/20160313214757492?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
(4)
<pre name="code" class="cpp">#include<iostream>using namespace std;int main(){    double weight ,height,biaozhun;    cout <<"请输入您的体重身高:"<<endl;    cin>>weight>>height;    biaozhun=height-100;   if(weight>biaozhun*1.2)    cout <<"超重"<<endl;    if(weight<biaozhun*0.8)    cout <<"超轻"<<endl;    else    cout <<"正常"<<endl;    return 0;}
运行结果:<img src="http://img.blog.csdn.net/20160313214813827?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
知识点总结:从这个程序中,巩固了自己对c++编程方法的掌握,巩固课上所学。学习心得:刚开始接触c++对一些基础知识掌握的还不够,还需要勤奋练习。又是会少打一个符号,一个标点,以后还需要更加细心。我相信自己以后会做的更好。加油郝昱猛!

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