第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;
}
*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 语言程序(二)
- 如何写好 C main 函数
- Lua和C语言的交互详解
- 关于C语言中参数的传值问题
- 简要对比C语言中三个用于退出进程的函数
- 深入C++中API的问题详解
- 基于C语言string函数的详解
- C语言中fchdir()函数和rewinddir()函数的使用详解
- C语言内存对齐实例详解
- C语言编程中统计输入的行数以及单词个数的方法
- C语言自动生成enum值和名字映射代码
- 使用C语言判断英文字符大小写的方法
- c语言实现的带通配符匹配算法
- C语言实现顺序表基本操作汇总
- C语言中计算正弦的相关函数总结
- 使用C语言详解霍夫曼树数据结构
- 探讨C语言的那些小秘密之断言
- C语言实现BMP转换JPG的方法
- 深入探讨C语言中局部变量与全局变量在内存中的存放位置
- C语言查找数组里数字重复次数的方法