为了账号安全,请及时绑定邮箱和手机立即绑定

为什么这个代码运行到最后输出不了结果就结束了

#include<stdio.h>
int main(void)
{
float Height;
float faHeight;
float moHeight;
char sex;
char sport;
char diet;
printf("Are you a boy(m) or a girl(f)\n");
scanf(" %c",&sex);
printf("please enter your father's height\n");
scanf("%f",&faHeight);
printf("please enter your mother's height\n");
scanf("%f",&moHeight);
if(sex=='f'||sex=='F')
{
    Height=(faHeight+moHeight)*0.54;
    
}
else
{
        Height=(faHeight*0.923+moHeight)/2;
}


printf("do you have a good diet(y/n)\n");
scanf(" %c",&diet);
if(diet=='y'||diet=='Y');
{
    Height = Height*1.015;
}
printf("do you like sport(y/n)\n");
scanf(" %c",sport);
if(sport=='y'||sport=='Y')
{
    Height = Height*1.02;
}
printf("your future Height will be %f\n",Height);
return 0;

}

正在回答

1 回答

倒数第7行,sport没有取地址。加一个&

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
C语言入门
  • 参与学习       926020    人
  • 解答问题       20793    个

C语言入门视频教程,带你进入编程世界的必修课-C语言

进入课程

为什么这个代码运行到最后输出不了结果就结束了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信