项目2 瘦子也伤不起

来源:互联网 发布:linux系统打开dos 编辑:程序博客网 时间:2024/04/30 01:39
#include <iostream>using namespace std;struct Tizhong{    char name;    char sex;//x为女性y为男性    double height;    double weight;};int main(){    Tizhong t;    cout<<"请输入姓名,性别(x.y),身高(cm),体重(kg)"<<endl;    cin>>t.name>>t.sex>>t.height>>t.weight;    double biao,chao;    if(t.sex=='y'||t.sex=='Y')        biao=(t.height-80)*0.7;    else        biao=(t.height-70)*0.6;    chao=(t.weight-biao)/biao;    if(chao>0.2)        cout<<"您的体重肥胖,oh 可要注意了";    else if(chao>0.1)        cout<<"您的体重过重,要合理饮食";    else if(chao>-0.1)        cout<<"您的体重正常,请继续保持";    else if(chao>-0.2)        cout<<"您的体重过轻,要合理饮食";    else        cout<<"您的体重体重不足,oh 要多吃饭啊";return 0;}


运行结果;

心得体会;对题目还不是很理解,通过看完其他同学的才好似恍然大悟,还是要多多借鉴,吸收为自己的东西

0 0
原创粉丝点击