第一周上机实践项目——胖子伤不起

01./*                

02.*程序的版权和版本声明部分:                

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

04.*All rights reserved.                

05.*文件名称:               

06.*作者:刘中林              

07.*完成日期:2013年 03月01日                
08.*版本号:v0.1               

09.*对任务及求解方法的描述部分:题意              

10.*输入描述:输入姓名、性别、体重、身高     

11.*问题描述:       

12.*程序输出:体重状况  

13.*问题分析:男女标准的不同            

14.*算法设计:standard1=(People1.height-80)*0.7;standard2=(People1.height-70)*0.6;             

15.*/     

16.*我的程序:
#include <iostream>
#include <string>
using namespace std;
struct People
{
    string name;
    char sex;
    double weight;
    double height;
};
int main()
{
    string s;
    People People1;
    double standard,overweight;
    cout<<"姓名:"<<endl;
    cin>>People1.name;
    cout<<"性别:"<<endl;
    cin>>People1.sex;
    cout<<"身高:"<<endl;
    cin>>People1.height;
    cout<<"体重:"<<endl;
    cin>>People1.weight;
    if(People1.sex=='m')
    {
        standard=(People1.height-80)*0.7;

    }
    else if(People1.sex=='w')
    {
        standard=(People1.height-70)*0.6;
    }
    overweight=(People1.weight-standard)/(standard);
    if((overweight<=0.1&&overweight>=0)||(overweight>=-0.1&&overweight<=0))
    {
        cout<<"正常"<<endl;
    }else if(overweight>-0.2&&overweight<-0.1)
    {
        cout<<"过轻"<<endl;
    }else if(overweight<=0.2&&overweight>=0.1)
    {
        cout<<"过重"<<endl;
    }else if(overweight>0.2)
    {
        cout<<"肥胖"<<endl;
    }else
    {
        cout<<"体重不足"<<endl;
    }

    return 0;
}


*样例输出:

第一周上机实践项目——胖子伤不起_第1张图片

*心得体会:这一局快弄毁俺了。。

你可能感兴趣的:(第一周上机实践项目——胖子伤不起)