您的位置:首页 > 其它

第一周项目2 胖子伤不起

2014-03-06 19:08 267 查看
/*

*Copyright (c)2013,烟台大学计算机学院

*All rights reserved.

*文件名称:test.cpp

*作者:孙玲倩

*完成日期:2014年3月6日

*版本号:v1.0

*输入描述:无

*问题描述:按照公式计算人的体重是否标准

*/
#include <iostream>

using namespace std;
struct Student
{
char name [18];
char sex;//男m/M,女w/W
double height;
double weight;

};

int main()
{
Student student;
double bw,ow;
cout<<"请输入姓名,性别,身高,体重:"<<endl;
cin>>student.name>>student.sex>>student.height>>student.weight;
if (student.sex='w')
{
bw=(student.height-70)*0.6;

}
else
{
bw=(student.height-80)*0.7;

}
ow=(student.weight-bw)/bw;
if(ow >-0.1)
{
cout<<"恭喜您,您的体重很标准哦!继续保持哦!"<<endl;

}
else if(ow >-0.2)
{
cout <<"亲,您有点瘦哦,注意保持营养啊!"<<endl;
}
else if(ow >0.1)
{
cout <<"亲,有点胖了,注意均衡饮食,保持身体健康哦!"<<endl;
}
else if (ow>0.2)
{
cout <<"亲,太胖了。该减肥了哦!"<<endl;
}
else
{
cout <<"亲,太瘦了!多吃点吧!"<<endl;
}

return 0;
}


心得体会:自己一开始写的可以运行但是不太符合标准,经过参考修改终于达标了!



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