m0_62400582 2021-10-06 20:18 采纳率: 0%
浏览 20

这个代码sport那里为什么不要输入求哥哥们解释一下

#include<stdio.h>
int main(){
char sex,sports,diet;
int faHeight,moHeight,fuHeight;
float a=0;
float b=0;
printf("Are you a boy(M) or a girl(F)?");
scanf("%c",&sex);
printf("%c\n",sex);
printf("Please input your father's height(cm):");
scanf("%d",&faHeight);
printf("Please input your mother's height(cm):");
scanf("%d",&moHeight);
printf("Do you like sports(Y/N)?");
scanf("%c",&sports);
printf("Do you have a good habit of diet(Y/N)?");
scanf("%c",&diet);
if(sex=='M'){
fuHeight=(faHeight+moHeight) 0.54;
}else{
fuHeight=(faHeight * 0.923 + moHeight) / 2;
}
if(sports=='Y')
a=fuHeight
0.02;
if(diet=='Y')
b=fuHeight*.015;
fuHeight+=(a+b);
printf("Your future height will be %d(cm)",fuHeight);
return 0;
}

  • 写回答

1条回答 默认 最新

  • CSDN专家-link 2021-10-06 20:21
    关注

    scanf("%c",&sports);这句之前加一句 getchar();

    评论

报告相同问题?

问题事件

  • 创建了问题 10月6日