胖子伤不起

*烟台大学计算机学院学生                                                                     
*All rights reserved.                                                    
*文件名称:胖子伤不起         
*作者:杨飞                                                                              
*完成日期:2013年2月27日                                                                   
*版本号:v1.0                                                                               
*对任务及求解方法的描述部分:胖子伤不起
               
*我的程序:
#include <iostream>
#include <string>
using namespace std;
struct students
{
    string name;
    string sex;
    double high;
    double weight;
};
int main()
{
    students xue;
    cout<<"请输入学生的姓名:";
    cin>>xue.name;
    cout<<"请输入学生的性别:";
    cin>>xue.sex;
    cout<<"请输入学生的身高:";
    cin>>xue.high;
    cout<<"请输入学生的体重";
    cin>>xue.weight;
    double b_biao,g_biao,b1,g1,b2,g2;
    double sheng1,sheng2;
    b_biao=(xue.high-80)*0.7;
    g_biao=(xue.high-70)*0.6;
    b1=b_biao*0.1;
    g1=g_biao*0.1;
    b2=b_biao*0.2;
    g2=g_biao*0.2;
    sheng1=b_biao-xue.weight;
    sheng2=g_biao-xue.weight;
    if(xue.sex=="男")
    {
        if((sheng1<=b1&&sheng1>=0)||(sheng1<0&&sheng1>=(-b1)))
            cout<<"正常,身体保持的很好!!!"<<endl;
        else if((sheng1<=b2&&sheng1>b1)||(sheng1<(-b1)&&sheng1>(-b1)))
        {
            if(sheng1<0)
                cout<<"过重,该减肥了"<<endl;
            else
                cout<<"过轻,多吃点"<<endl;
        }
        else
        {
            if(sheng1<0)
                cout<<"超重,不得不减肥了"<<endl;
            else
                cout<<"太轻,使劲吃啊"<<endl;
      }
    }
    if(xue.sex=="女")
    {
        if((sheng2<=g1&&sheng2>=0)||(sheng2<0&&sheng2>=(-g1)))
            cout<<"正常,身体保持的很好!!!"<<endl;
        else if((sheng2<=g2&&sheng1>g1)||(sheng1<(-g1)&&sheng1>(-g1)))
        {
            if(sheng2<0)
                cout<<"过重,该减肥了"<<endl;
            else
                cout<<"过轻,多吃点"<<endl;
        }
         else
        {
            if(sheng2<0)
                cout<<"超重,不得不减肥了"<<endl;
            else
                cout<<"太轻,使劲吃啊"<<endl;
      }
      }
    return 0;
}

运行结果:胖子伤不起_第1张图片

心得体会:江哥别怪我,是张梦佳让我写你的哈哈,你要写个他的哦哈哈!!!

           

你可能感兴趣的:(胖子伤不起)