| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 581 人关注过本帖
标题:怎么修改呢
只看楼主 加入收藏
aa985754755
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-4-11
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
怎么修改呢
#include<stdio.h>
void main()
{
    float faHeight,moHeight,T;
    char sex,sports,diet;
    printf("父亲身高:");
    scanf("%f",&faHeight);
    printf("母亲身高:");
    scanf("%f",&moHeight);
    printf("性别(M/F):");
    scanf("%*c%c",&sex);
    printf("是否喜欢运动(Y/N):");
    scanf("%*c%c",&sports);
    printf("饮食是否良好(Y/N):");
    scanf("%*c%c",&diet);

   if(sex=='M')

        {if(sports=='Y')
         T=(faHeight+moHeight)*0.54*1.02;
            {if(diet=='Y')
             T=(faHeight+moHeight)*0.54*1.02*1.015;
            else
             T=(faHeight+moHeight)*0.54*1.02;}
         }else
        {if(diet=='Y')
         T=(faHeight+moHeight)*0.54*1.015;
        else
            T=(faHeight+moHeight)*0.54;}
   else
        {if(sports=='Y')
         T=(faHeight*0.923+moHeight)/2*1.02;
           {if(diet=='Y')
            T=(faHeight*0.923+moHeight)/2*1.02*1.015;
           else
            T=(faHeight*0.923+moHeight)/2*1.02;}
        else}
           {if(diet=='Y')
            T=(faHeight*0.923+moHeight)/2*1.015;
           else
            T=(faHeight*0.923+moHeight)/2;}
}
搜索更多相关主题的帖子: 修改 printf scanf 是否 if 
2018-04-11 18:22
nosnoy
Rank: 9Rank: 9Rank: 9
来 自:mcu
等 级:贵宾
威 望:14
帖 子:541
专家分:1178
注 册:2016-9-17
收藏
得分:10 
请保持良好的代码规范 ,缩进 {}对齐
你就能找到原因了

穷举是最暴力的美学
2018-04-11 20:21
dzy123
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:5
帖 子:379
专家分:820
注 册:2013-4-18
收藏
得分:10 
float faHeight,moHeight,T;
    char sex,sports,diet;
    printf("父亲身高:");
    scanf("%f",&faHeight);
    printf("母亲身高:");
    scanf("%f",&moHeight);
    printf("性别(M/F):");
    scanf("%*c%c",&sex);
    printf("是否喜欢运动(Y/N):");
    scanf("%*c%c",&sports);
    printf("饮食是否良好(Y/N):");
    scanf("%*c%c",&diet);
   if(sex=='M')
      if(sports=='Y')
            { T=(faHeight+moHeight)*0.54*1.02;
             if(diet=='Y')
                T=(faHeight+moHeight)*0.54*1.02*1.015;
             else
                T=(faHeight+moHeight)*0.54*1.02;}
      else
             if(diet=='Y')
                T=(faHeight+moHeight)*0.54*1.015;
             else
                T=(faHeight+moHeight)*0.54;
   else
      if(sports=='Y')
            {T=(faHeight*0.923+moHeight)/2*1.02;
            if(diet=='Y')
                T=(faHeight*0.923+moHeight)/2*1.02*1.015;
            else
                T=(faHeight*0.923+moHeight)/2*1.02;}
      else
           if(diet=='Y')
               T=(faHeight*0.923+moHeight)/2*1.015;
           else
               T=(faHeight*0.923+moHeight)/2;
    printf("%f",T);      
2018-04-12 09:26
dzy123
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:5
帖 子:379
专家分:820
注 册:2013-4-18
收藏
得分:0 
在if中多于一条语句才用{}这样好些
2018-04-12 09:27
快速回复:怎么修改呢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022551 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved