hyzz1017 2022-10-09 21:24 采纳率: 35.3%
浏览 15
已结题

运行结果出来问题,求看

编译正常,运行结果一直是正常,不知道问题出在哪儿,可以帮忙看看吗


#include<stdio.h>
int main()
{
    int age;
    char gender;
    float BMI,height,weight;
    printf("please input your gender(M or F),age,height(m) and weight(kg): \n");//M为男,F为女 
    scanf("%c %d %f %f",&gender,&age,&height,&weight);
    BMI=weight/(height*height);
    if(age>=18)
    {
       if(gender=='M')
       {
             if(BMI<18.5)
             printf("your weight:偏瘦");
          else if(18.5<BMI<24)
          printf("your weight:正常"); 
          else if(24<=BMI<28)
          printf("your weight:偏胖");
          else
          printf("your weight:非常肥胖"); 
       } 
        else
        {
            if(BMI<18)
            printf("your weight:偏瘦"); 
            else if(18<=BMI<23.5)
            printf("your weight:正常"); 
            else if(23.5<=BMI<27)
            printf("your weight:偏胖");
            else
            printf("your weight:非常肥胖");
        }          
    }
    else if(10<=age<18)
    {
        if(gender=='M')
        {
          if(BMI<17)
          printf("your weight:偏瘦");
          else if(17<=BMI<23.5)    
          printf("your weight:正常");
          else if(23.5<=BMI<27)
          printf("your weight:偏胖");
          else
          printf("your weight:非常肥胖");
        }
        else
        {
            if(BMI<16.5)
            printf("your weight:偏瘦");
            else if(16.5<=BMI<23)
            printf("your weight:正常");
            else if(23<=BMI<26.5)
            printf("your weight:偏胖");
            else
            printf("your weight:非常肥胖");
        }
    }
    else if(3<=age<10)
    {
        if(gender=='M')
        {
            if(BMI<19)
            printf("your weight:偏瘦");
            else if(19<=BMI<24.5)
            printf("your weight:正常");
            else if(24.5<=BMI<29)
            printf("your weight:偏胖");
            else
            printf("your weight:非常肥胖");
        }
        else
        {
            if(BMI<18.5)
            printf("your weight:偏瘦");
            else if(18.5<=BMI<24)
            printf("your weight:正常");
            else if(24<=BMI<28.5)
            printf("your weight:偏胖");
            else
            printf("your weight:非常肥胖");
        }
    }
    else
    {
        if(gender=='M')
        {
            if(BMI<19.5)
            printf("your weight:偏瘦");
            else if(19.5<=BMI<25)
            printf("your weight:正常");
            else if(25<=BMI<28.5)
            printf("your weight:偏胖");
            else
            printf("your weight:非常肥胖");
        }
        else
        {
            if(BMI<19)
            printf("your weight:偏瘦");
            else if(19<=BMI<25)
            printf("your weight:正常");
            else if(25<=BMI<28.5)
            printf("your weight:偏胖");
            else
            printf("your weight:非常肥胖");
        }
    }
    return 0;
}

  • 写回答

4条回答 默认 最新

  • 叶落花枯 2022-10-09 21:39
    关注

    18.5<BMI<24 关系运算符不能连着写,改成 BMI>18.5 && BMI<24
    其他也一样改

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月9日
  • 已采纳回答 10月9日
  • 创建了问题 10月9日

悬赏问题

  • ¥15 35114 SVAC视频验签的问题
  • ¥15 impedancepy
  • ¥15 在虚拟机环境下完成以下,要求截图!
  • ¥15 求往届大挑得奖作品(ppt…)
  • ¥15 如何在vue.config.js中读取到public文件夹下window.APP_CONFIG.API_BASE_URL的值
  • ¥50 浦育平台scratch图形化编程
  • ¥20 求这个的原理图 只要原理图
  • ¥15 vue2项目中,如何配置环境,可以在打完包之后修改请求的服务器地址
  • ¥20 微信的店铺小程序如何修改背景图
  • ¥15 UE5.1局部变量对蓝图不可见