问题及代码
- /*
- *ALL rights reserved.
- *文件名称:shibazhouxiangmu3
- *作者:李长鸿
- *完成时间:2014.12.23
- *问题描述:体重与健康
- */
- #include <iostream>
- #include<string>
- using namespace std;
- struct Preson
- {
- string name;
- char sex;
- double high;
- double weight;
- } person;
- int main()
- {
- cout<<"请输入您的姓名,性别,身高(cm),体重(kg): "<<endl;
- cin>>person.name>>person.sex>>person.high>>person.weight;
- double p1,p2;
- if(person.sex=='W')
- p1=(person.high-70)*0.6;
- else p1=(person.high-80)*0.7;
- p2=(person.weight-p1)/p1;
- if(p2<=0.1&&p2>=-0.1)
- cout<<"恭喜您!您不必担心,您的体重为正常体重。继续保持哦!"<<endl;
- else if(-0.1>p2&&-0.2<p2)
- cout<<"额,您的体重偏轻啦!您比较瘦啦,为了身体健康,得多吃点多锻炼额!"<<endl;
- else if(0.1<p2&&0.2>p2)
- cout<<"额,您的体重偏重额!吃货就暂时和美食保持距离;宅男宅女们就多出去溜达溜达吧!"<<endl;
- else if(0.2<p2)
- cout<<"啊,您已经达到肥胖啦!!该怎么做,你懂滴。好吃的,还是少吃点吧:即使很累,还是运动去吧。"<<endl;
- else
- cout<<"额,您已经体重严重过轻了!被风吹跑了多不划算啊——烟台的风可不是盖的呢!所以,使劲的吃,使劲的运动吧!"<<endl;
- return 0;
- }