#include <stdio.h>
int main()
{
char sex;
printf("Are you a boy(M) or a girl(F)?");
scanf("%c",&sex);
float faHeight,moHeight,h;
printf("Please input your father's height(cm):");
scanf("%f",&faHeight);
printf("Please input your mother's height(cm):");
scanf("%f",&moHeight);
if(sex=='M'){
h=(faHeight+moHeight)*0.54;
}else if(sex=='F'){
h=(faHeight*0.923+moHeight)/2;
}
getchar();
char sports;
printf("Do you like sports(Y/N)?");
scanf("%c",&sports);
if(sports=='Y'){
h=h*0.02+h;
}
getchar();
char diet;
printf("Do you have a good habit of diet(Y/N)?");
scanf("%c",&diet);
if(diet=='Y'){
h=h*0.015+h;
}
printf("Your future height will be %.0f(cm)",h);
}
关于getchar()
解释:为什么scanf被跳过或不执行https://blog.csdn.net/HNAKXR/article/details/81047391