注册 登录
编程论坛 新人交流区

[求助]为啥这代码在编译时显示许多变量没定义

zsx369530691 发布于 2007-10-20 17:01, 235 次点击

#include<math.h>
main()
{
char sex;
char sports;
char diet;

float myHeight;
float faHeight;
float moHeight;
printf("Are you a boy(M) or a girl(F)?");
scanf("% c", &sex);
printf("please input your father's height(cm):");
scanf("%f", &faHeight);
printf("please input your mother's height(cm):");
scanf("%f",&moHeight);
printf("DO you have a good habit of diet(Y/N)?");
scanf("%c",&diet);

printf("do you like sports(Y/N)?");
scanf("%c",&sports);
if(sex ==`M` || sex ==`m`)
myheight = (faHeight + moHeight)*0.54;
else
myheight = (faHeight *0.923 +moHeight) / 2.0;
if(sports == `y` || sports ==`Y`)
myHeight =myHeight * (1 + 0.02);
if(diet ==`Y` || diert ==`y`)
myHeight = myHeight * (1 + 0.015);
printf("your future height will be %f(cm)\n",myHeight);

}

0 回复
1