胖子伤不起

来源:互联网 发布:淘宝的优惠券怎么设置 编辑:程序博客网 时间:2024/04/28 20:52
/**程序的版权和版本声明部分:*Copyright(c)2013,烟台大学计算机学院学生*All rights reserved.*文件名称:*作者:李新鹏*完成日期:2014年3月24日*版本号:v0.1*对任务及求解方法的描述部分:*输入描述:无*问题描述:计算体重状况。*程序输入:姓名,性别,身高,体重*程序输出:体重状况*问题分析:*算法设计:*我的程序:*/#include <iostream>using namespace std;struct people{    char name[20];    char sex;    double height;    double weight;};int main(){    people p1;    double bweight,cweight;    cout<<"请输入姓名,性别,身高,体重:";    cin>>p1.name>>p1.sex>>p1.height>>p1.weight;    if(p1.sex=='f')    {        bweight=(p1.height-80)*0.7;    }    else    {        bweight=(p1.height-70)*0.6;    }    cweight=((p1.weight-bweight)/bweight);    if(cweight>=-0.1&&cweight<=0.1)    {        cout<<"恭喜您的体重正常请保持"<<endl;    }    else if(cweight<-0.1&&cweight>=-0.2)    {        cout<<"您的体重过轻请注意增重"<<endl;    }    else if(cweight>0.1&&cweight<=0.2)    {        cout<<"您的体重过重请注意锻炼"<<endl;    }    else if(cweight<-0.2)    {        cout<<"您的体重不足应注意饮食"<<endl;    }    else    cout<<"你的体重处于肥胖状态请进行魔鬼式减肥"<<endl;    return 0;}

运行结果:

心得体会:

0 0
原创粉丝点击