项目2--胖子伤不起
2014-02-27 17:03
351 查看
/* *程序的版权和版本声明部分: *Copyright(c)2013,烟台大学计算机学院学生 *All rights reserved. *文件名称: *作者:尚振伟 *完成日期:2014年2月27日 *版本号:v0.1 *对任务及求解方法的描述部分: *输入描述:无 *问题描述:根据世界卫生组织推荐的体重标准,计算一个人的体重情况。 *程序输入: *程序输出: *问题分析: *算法设计: *我的程序: */ #include <iostream> using namespace std; struct People { char name[20]; char sex; double height; double weight; } peo; int main() { double bweight,overweight; //分别代表标准体重和超重百分比 cout<<"请输入姓名 性别 身高 体重"<<endl; cin>>peo.name>>peo.sex>>peo.height>>peo.weight; if(peo.sex=='F') //F和M分别代表女性和男性 { bweight=(peo.height-70)*0.6; //女性的标准体重 } else { bweight=(peo.height-80)*0.7; //男性的标准体重 } overweight=(peo.weight-bweight)/bweight; if(overweight<0.1&&overweight>-0.1) { cout<<"正常"<<endl; } else { if(overweight>=0.1&&overweight<0.2) { cout<<"过重"<<endl; } else { if(overweight<=-0.1&&overweight>-0.2) { cout<<"过轻"<<endl; } else { if(overweight>=0.2) { cout<<"肥胖"<<endl; } else { cout<<"体重不足"<<endl; } } } } return 0; }
结果展示:
心得体会:用char类型定义变量sex,不能输入汉字,只好用F和M分别代表女性和男性。
相关文章推荐
- vc++6.0快捷键小结
- CentOS 6.5系统中安装配置MySQL数据库
- mysql 配置日志及MONyog监控工具使用
- Xceed dataGrid scroll FixedColumnCount
- mysql的limit语句
- Android Animation时间插入器Interpolator
- mahout聚类
- configure.in Makefile.am解析
- 伪元素 :Before 和 :After的学习
- DevExpress Xaf入门——关于一对多关系的配置(DC模式)
- 【技术】js控制滚动条位置
- 浅析android应用增量升级(差分升级)
- ORA-01157: cannot identify/lock data file
- disk benchmark和bonnie++,noatime对性能的影响
- 程序员的本职工作和私活孰轻孰重?
- Tao-ReviewBoard 提交时报出 HttpClient.excuteMethod Error HttpCode=400 的错误
- 好用的淘宝开源工具tsar工具
- jquery 侧边商品分类二级导航菜单样式
- linux,串口读取指定数目的字节,串口读取数据错误
- sencha2.3与phonegap的配置