胖子的纠结

 02.* Copyright (c) 2013, 烟台大学计算机学院
03.* All rights reserved.
04.* 作    者:石尧
05.* 完成日期:2014 年 2 月 28 日
06.* 版 本 号:v1.0
07.*/
#include <iostream>
#include <string.h>
struct xinxi
{
    char name[20];
    char sex[8];
    int age;               \\声明结构体xinxi
    double hight;
    double weight;
}s;
using namespace std;
void output();
int main()
{
    cout<<"请输入姓名:";
    cin>>s.name;
    cout<<endl;
    cout<<"请输入性别:";
    cin>>s.sex;
    cout<<endl;
    cout<<"请输入年龄:";
    cin>>s.age;
    cout<<endl;
    cout<<"请输入身高:";
    cin>>s.hight;
    cout<<endl;
    cout<<"请输入体重:";
    cin>>s.weight;
    cout<<endl;
    cout<<s.name<<endl;
    cout<<s.sex<<endl;       \\输出结构体内容
    cout<<s.age<<endl;
    cout<<s.hight<<endl;
    cout<<s.weight<<endl;
   output();
    return 0;
}
void output ()
{
 float n;   \\用n表示标准体重
    if(strcmp(s.sex,"G")==0)
    {
        n=(s.hight-80)*0.7;
        if(s.weight<=(n*1.1)||s.weight>=(n*0.9))
        cout<<"您的体重正常!"<<endl;
        else if(s.weight>=(n*1.1)&&s.weight<=(n*1.2))
        cout<<"您的体重过重,请合理饮食!"<<endl;
        else if(s.weight>=(n*0.8)&&s.weight<=(n*0.9))
        cout<<"您的体重过轻,请合理饮食!"<<endl;
    }
    if(strcmp(s.sex,"M")==0)
    {
        n=(s.hight-70)*0.6;
        if(s.weight<=(n*1.1)||s.weight>=(n*0.9))
        cout<<"您的体重正常!"<<endl;
        else if(s.weight>=(n*1.1)&&s.weight<=(n*1.2))
        cout<<"您的体重过重,请合理饮食!"<<endl;
        else if(s.weight>=(n*0.8)&&s.weight<=(n*0.9))
        cout<<"您的体重过轻,请合理饮食!"<<endl;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值