肥胖问题 法二

来源:互联网 发布:69是什么意思网络用语 编辑:程序博客网 时间:2024/04/25 17:23
/** Copyright (c) 2014, 烟台大学计算机学院* All rights reserved.* 作    者:王颖* 完成日期:2014 年 3 月 2 日* 版 本 号:v1.0* 输入描述: 无* 问题描述:肥胖问题* 程序输出:略* 问题分析:略* 算法设计:略*/#include <iostream>using namespace std;struct People{char name[6];char nex;//M男,W女防止乱码!!!!!double height;double weight;};void output(char [6],char ,double ,double);//void output(char ,char ,double ,double);靠靠靠!!!之前是这么写的,结果错了!!int main(){    People peo;   cout<<"please into name,nex(男的W女的M),height,weight:"<<endl;   cin>>peo.name>>peo.nex;   while(peo.nex!='M'&&peo.nex!='W')   {       cout<<"请重新输入:"<<endl;       cin>>peo.nex;   }   cin>>peo.height>>peo.weight;   output(peo.name,peo.nex,peo.height,peo.weight);    return 0;}void output(char name[6],char nex,double height,double weight){    double t=0,s=0;    if(nex=='W')    {      t=(height-80)*0.7;    }     else     {         t=(height-80)*0.6;     }        s=(weight-t)/t;        if(s>-0.1)    {        cout<<name[6]<<"太帅啦!恭喜您!您的体重为标准体重!!"<<endl;    }    else if(s>0.1)    {        cout<<name[6]<<"您的体重过重,注意减肥啦!"<<endl;    }    else if(s>-0.2)    {        cout<<name[6]<<"您的体重过轻,平时要多吃点啦"<<endl;    }    else if(s>0.2)    {        cout<<name[6]<<"啊偶~您太注意减肥了,体重不足对您的身体可不好呦!"<<endl;    }    else    {        cout<<name[6]<<"能不能干啦?!!!吃那么多!太肥胖啦小心生病!"<<endl;    }}

心得体会:哎呀!!!可算是找着问题了啊!!!!!

0 0