L1-7 吃鱼还是吃肉(c++)_结构体

L1-7 吃鱼还是吃肉

国家给出了 8 岁男宝宝的标准身高为 130 厘米、标准体重为 27 公斤;8 岁女宝宝的标准身高为 129 厘米、标准体重为 25 公斤。

现在你要根据小宝宝的身高体重,给出补充营养的建议。

输入格式:
输入在第一行给出一个不超过 10 的正整数 N,随后 N 行,每行给出一位宝宝的身体数据:

性别 身高 体重

其中性别是 1 表示男生,0 表示女生。身高和体重都是不超过 200 的正整数。

输出格式:
对于每一位宝宝,在一行中给出你的建议:

如果太矮了,输出:duo chi yu!(多吃鱼);
如果太瘦了,输出:duo chi rou!(多吃肉);
如果正标准,输出:wan mei!(完美);
如果太高了,输出:ni li hai!(你厉害);
如果太胖了,输出:shao chi rou!(少吃肉)。
先评价身高,再评价体重。两句话之间要有 1 个空格。

输入样例:
4
0 130 23
1 129 27
1 130 30
0 128 27

输出样例:
ni li hai! duo chi rou!
duo chi yu! wan mei!
wan mei! shao chi rou!
duo chi yu! shao chi rou!

#include <iostream>

using namespace std;
struct node{
    int sex;
    int high;
    int weight;
}arr[10];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i].sex>>arr[i].high>>arr[i].weight;
    }

    for(int i=0;i<n;i++){
        if(arr[i].sex==1){
            if(arr[i].high==130){
                cout<<"wan mei!"<<" ";
                if(arr[i].weight==27){
                    cout<<"wan mei!"<<endl;
                }
                else if(arr[i].weight>27){
                    cout<<"shao chi rou!"<<endl;
                }
                else if(arr[i].weight<27){
                    cout<<"duo chi rou!"<<endl;
                }
            }else if(arr[i].high>130){
                cout<<"ni li hai!"<<" ";
                if(arr[i].weight==27){
                    cout<<"wan mei!"<<endl;
                }
                else if(arr[i].weight>27){
                    cout<<"shao chi rou!"<<endl;
                }
                else if(arr[i].weight<27){
                    cout<<"duo chi rou!"<<endl;
                }
            }else if(arr[i].high<130){
                cout<<"duo chi yu!"<<" ";
                if(arr[i].weight==27){
                    cout<<"wan mei!"<<endl;
                }
                else if(arr[i].weight>27){
                    cout<<"shao chi rou!"<<endl;
                }
                else if(arr[i].weight<27){
                    cout<<"duo chi rou!"<<endl;
                }
            }
        }
        else{
            if(arr[i].high==129){
                cout<<"wan mei!"<<" ";
                if(arr[i].weight==25){
                    cout<<"wan mei!"<<endl;
                }
                else if(arr[i].weight>25){
                    cout<<"shao chi rou!"<<endl;
                }
                else if(arr[i].weight<25){
                    cout<<"duo chi rou!"<<endl;
                }
            }else if(arr[i].high>129){
                cout<<"ni li hai!"<<" ";
                if(arr[i].weight==25){
                    cout<<"wan mei!"<<endl;
                }
                else if(arr[i].weight>25){
                    cout<<"shao chi rou!"<<endl;
                }
                else if(arr[i].weight<25){
                    cout<<"duo chi rou!"<<endl;
                }
            }else if(arr[i].high<129){
                cout<<"duo chi yu!"<<" ";
                if(arr[i].weight==25){
                    cout<<"wan mei!"<<endl;
                }
                else if(arr[i].weight>25){
                    cout<<"shao chi rou!"<<endl;
                }
                else if(arr[i].weight<25){
                    cout<<"duo chi rou!"<<endl;
                }
            }
        }

    }
    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值