第十七周项目3胖子伤不起

来源:互联网 发布:淘宝店铺动态评分4.6 编辑:程序博客网 时间:2024/05/21 06:40
/* *Copyright(c)2014,烟台大学计算机学院 *All rights reserved. *文件名称:test.cpp *作者:曾晓 *完成日期:2014年 12月 18日 *版本号:v1.0 */#include <iostream>#include <cstdio>using namespace std;struct Person{    char name[20];    char sex;    int height;    double weight;};int main(){    Person  person;    double std_weight,over;    cout<<"请输入您的姓名、性别、身高和体重:"<<endl;    cin>>person.name>>person.sex>>person.height>>person.weight;    if(person.sex=='M')    std_weight=(person.height-80)*0.7;    else if(person.sex=='F')    std_weight=(person.height-70)*0.6;    if(person.weight>=std_weight*0.9 && person.weight<=std_weight*1.1)        cout<<"您的体重正常哦不用早起跑步了嘻嘻嘻"<<endl;    else if(person.weight>std_weight*1.1 && person.weight<=std_weight*1.2)        cout<<"您的体重过重哦看来要早起了好忧桑"<<endl;        else if(person.weight>std_weight*0.8 && person.weight<std_weight*0.9)            cout<<"您的体重过轻以后不用早起跑步了!"<<endl;    else if(person.weight>std_weight*1.2)        cout<<"您原来是个胖子!"<<endl;    else if(person.weight<std_weight*0.8)        cout<<"您体重不足得多吃点了!"<<endl;     over=(person.weight/std_weight)*100;     cout<<over<<"%"<<endl;    return 0;}


运行结果:

编了很久终于写出来了
0 0