| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2461 人关注过本帖
标题:错误显示illegal else without matching if,求大神指点
取消只看楼主 加入收藏
shallwt
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2018-10-3
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
错误显示illegal else without matching if,求大神指点

#include <stdlib.h>
#include <math.h>
#include <stdio.h>
int main()
{
        char diet;
    char sports;
    char sex;
    char M;
    char F;
    char Y;
    char N;
    float faHeight;
    float moHeight;
    float myHeight;
    printf("please enter your Father's Height and your Mother's Height(cm)\n");
    scanf("%f%f",&faHeight,&moHeight);
    printf("if you are a boy,please enter'M',or enter'F'\n");
    scanf(" %c",&sex);
    if(sex==M);
    {
        myHeight=(faHeight+moHeight)*0.54;
        printf("if you love sports ,please enter Y,or enter N\n");
        scanf(" %c",&sports);
        if(sports==Y);
        {
            myHeight=myHeight*(1+0.02);
            printf("if you have healthy diet,please enter'Y',or enter'N'\n");
            scanf(" %c",&diet);
            if(diet==Y);
            {
                myHeight=myHeight*(1+0.02);
                printf("your future height:%f\n",myHeight);
            }
            else if (diet==N);
            {
                printf("your future height:%f\n",myHeight);
            }
        }
        else if(sports==N);
        {
            printf("if you have healthy diet,please enter'Y',or enter'N'\n");
            if(diet==Y);
            {
                myHeight=myHeight*(1+0.02);
                printf("your future height:%f\n",myHeight);
            }
            else(diet==N);
            {
                printf("your future height:%f\n",myHeight);
            }
        }
    }
    else(sex==F);
    {
        myHeight=(faHeight*0.923+moHeight)/2;
        if(sports==Y);
        {
            myHeight=myHeight*(1+0.02);
            printf("if you have healthy diet,please enter'Y',or enter'N'\n");
            scanf(" %c",diet);
            if(diet==Y);
            {
                myHeight=myHeight*(1+0.02);
                printf("your future height:%f\n",myHeight);
            }
            else(diet==N);
            {
                printf("your future height:%f\n",myHeight);
            }
        }
        else(sports==N);
        {
            printf("if you have healthy diet,please enter'Y',or enter'N'\n");
            if(diet==Y);
            {
                myHeight=myHeight*(1+0.02);
                printf("your future height:%f\n",myHeight);
            }
            else(diet==N);
            {
                printf("your future height:%f\n",myHeight);
            }
        }
    }
   
    return 0;  
}
2018-10-03 18:29
shallwt
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2018-10-3
收藏
得分:0 
回复 2楼 吹水佬
那我应该怎么使用呢
2018-10-03 18:51
快速回复:错误显示illegal else without matching if,求大神指点
数据加载中...
 
   



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

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