/*
*Copyright (c) 2014,烟台大学计算机学院
*All right reserved.
*文件名称:test.cpp
*作 者:韩双志
*完成日期:2016年3月8日
*版本号:v1.0
*
*问题描述:成年男性的标准体重公式为:标准体重(kg)=身高(cm)-100,超标准体重20%为超重,比标准体重轻20%为超轻。请编写c++程序,输入身高和体重,完成下面任务:
1.计算并输入标准体重,
2.计算出标准体重,当超重时,请给出提示。
3.计算出标准体重,当超重时给出提示,不超重时也给出提示。
4.计算出标准体重,输出体重状态(正常、超重、超轻)
*/
#include <iostream>
using namespace std;
int main()
{
double weight,high,stander_weight;
cin>>high>>weight;
stander_weight=high-100;
cout<<stander_weight;
if(weight>stander_weight*1.2)
cout<<"超重"<<endl;
if(weight<stander_weight*0.8)
cout<<"超轻"<<endl;
if(weight>stander_weight*0.8&&weight<stander_weight*1.2)
cout<<"正常"<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
double weight,high,stander_weight;
cin>>high>>weight;
stander_weight=high-100;
cout<<stander_weight;
if(weight>stander_weight*1.2)
cout<<"超重"<<endl;
if(weight<stander_weight*0.8)
cout<<"超轻"<<endl;
if(weight>stander_weight*0.8&&weight<stander_weight*1.2)
cout<<"正常"<<endl;
return 0;
}
运行结果:
知识点总结:
从这个程序中,进一步巩固了对简单程序结构的认识,也学会了利用输入的结构方法。
学习心得:
一开始写程序,将endl后面的分号写成了汉字标点,于是一番纠结。等于把这就是积累。在错误中成长,我能行!