| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 391 人关注过本帖
标题:求高手指点迷津,可否帮忙检查一下,怎么输不出来呀
只看楼主 加入收藏
羽墨离殇
Rank: 2
等 级:论坛游民
帖 子:13
专家分:11
注 册:2012-3-10
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
求高手指点迷津,可否帮忙检查一下,怎么输不出来呀
#include <stdio.h>
#include <stdlib.h>

int main()
{
    float faHeight,moHeight,yoHeight;
    char sex,sports,diet;
    scanf("%c\n%f\n%f\n%c\n%c",&sex,&faHeight,&moHeight,&sports,&diet);
    if(sex==('M'||'n'))
    {
        yoHeight=(faHeight+moHeight)*0.54;
        if(sports==('Y'||'y'))
        {
             yoHeight*=1+0.02;
             if(diet==('Y'||'y'))
             {
                 yoHeight*=1+0.015;
                 printf("Your future height will be %.0f(cm)\n",yoHeight);
             }
             else
             {
                printf("Your future height will be %.0f(cm)\n",yoHeight);
             }
        }
        else
        {
             if(diet==('Y'||'y'))
            {
                yoHeight*=1+0.015;
                printf("Your future height will be %.0f(cm)\n",yoHeight);
            }
            else
            {
                printf("Your future height will be %.0f(cm)\n",yoHeight);
            }
        }
    }
    else if(sex==('F'||'f'))
{
    yoHeight=(faHeight*0.923+moHeight)/2;
        if(sports==('Y'||'y'))
            {
            yoHeight*=1+0.02;
                if(diet==('Y'||'y'))
                {
                yoHeight*=1+0.015;
                printf("Your future height will be %.0f(cm)\n",yoHeight);
                }
                else
                {
                printf("Your future height will be %.0f(cm)\n",yoHeight);
                }
            }
        else
            {
                if(diet==('Y'||'y'))
                {
                yoHeight*=1+0.015;
                printf("Your future height will be %.0f(cm)\n",yoHeight);
                }
                else
                {
                printf("Your future height will be %.0f(cm)\n",yoHeight);
                }
            }
}

    return 0;
}
搜索更多相关主题的帖子: 检查 include future sports 
2012-03-29 20:41
于祥
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1047
专家分:4132
注 册:2011-4-24
收藏
得分:5 
程序代码:
#include <stdio.h>

int main()

 {
     double faHeight,moHeight,yoHeight;
     char sex,sports,diet;
     scanf("%c %lf %lf %c %c",&sex,&faHeight,&moHeight,&sports,&diet);
     if(sex == 'M'||sex == 'm')
     {
         yoHeight=(faHeight+moHeight)*0.54;
         if(sports == 'Y'||sports == 'y')
         {
              yoHeight*=1+0.02;
              if(diet == 'Y'||diet == 'y')
              {
                  yoHeight*=1+0.015;
                  printf("Your future height will be %.0f(cm)\n",yoHeight);
              }
              else
              {
                 printf("Your future height will be %.0f(cm)\n",yoHeight);
              }
         }
         else
         {
              if(diet == 'Y'||diet == 'y')
             {
                 yoHeight*=1+0.015;
                 printf("Your future height will be %.0f(cm)\n",yoHeight);
             }
             else
             {
                 printf("Your future height will be %.0f(cm)\n",yoHeight);
             }
         }
     }

 else if(sex == 'F'||sex == 'f')

 {
     yoHeight=(faHeight*0.923+moHeight)/2;
         if(sports == 'Y'||sports == 'y')
             {
             yoHeight*=1+0.02;
                 if(diet == 'Y'||diet == 'y')
                 {
                 yoHeight*=1+0.015;
                 printf("Your future height will be %.0f(cm)\n",yoHeight);
                 }
                 else
                 {
                 printf("Your future height will be %.0f(cm)\n",yoHeight);
                 }
             }
         else
             {
                 if(diet == 'Y'||diet == 'y')
                 {
                 yoHeight*=1+0.015;
                 printf("Your future height will be %.0f(cm)\n",yoHeight);
                 }
                 else
                 {
                 printf("Your future height will be %.0f(cm)\n",yoHeight);
                 }
             }

 }

 else printf("输入有误!");

    return 0;

 } 

好了!你的判断条件太主观了!

最基础的往往是你最容易忽略的!
2012-03-29 22:53
zhangxiangD
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:39
专家分:119
注 册:2011-12-20
收藏
得分:5 
程序是对的,可惜算法不科学。
2012-03-29 23:32
moonnight
Rank: 5Rank: 5
等 级:职业侠客
帖 子:158
专家分:380
注 册:2012-3-17
收藏
得分:5 
你scanf输入,每次输入你要敲两个回车或一个空格一个回车,看了楼的,他的scanf也不是很好,最好两个格式符之间什么都不要
2012-03-29 23:50
小赵q1
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:4
帖 子:492
专家分:777
注 册:2011-8-26
收藏
得分:5 
scanf()中%d和%d之间最好什么都不要加,输入的时候把两个数之间用空格隔开就可以了,1楼的中间有空格,输入的时候容易出问题。如果中间需要加逗号,最好是在输入前面提示下中间用逗号隔开。
2012-03-30 04:42
快速回复:求高手指点迷津,可否帮忙检查一下,怎么输不出来呀
数据加载中...
 
   



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

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