c语言的一道题,画流程图,该程序用于计算小孩身高(画出流程图、粘贴代码和程序结果)

1、 该程序用于计算小孩身高。(画出流程图、粘贴代码和程序结果) 设hf为其父身高,hm为其母身高,则小孩身高预测公式为: 男性身高 = ( hf + hm )*0.54 cm 女性身高 = ( hf * 0.923 + hm ) / 2 cm 此外,经常体育锻炼可以增高2% ,良好的卫生饮食可以增高1.5% 提示: a) 性别变量sex、运动变量sports、饮食变量diet应该是字符变量、字符M表示男、字符F表示女,字符Y表示是,字符N表示否定 b) 确定从键盘输入的量有sex、hf、hm、sports、diet 。待求的量为身高hf c) 在程序中每一次输入前应该有提示信息
匿名用户    2015-04-07 18:10    

满意回答

#includevoid main(){ float hf,hm,h; char sex,sports,diet; printf("Please type in the sex(M/F):"); scanf("%c",&sex); printf("Please type in the height of father:"); scanf("%f",&hf); printf("Please type in the height of mother:"); scanf("%f",&hm); printf("Do sports(Y/N):"); getchar(); ; ; ; ; ; ; ; ; ; ;//没特别的意思,只是揭立消除回车键的影响 scanf("%c",&sports); printf("Have a diet(Y/N):"); getchar(); ; ; ; ; ; ; ; ; ; ; ;//没特别的意思,只是消除回车键残稼的影香眠悟响 scanf("%d",&diet); if('m'==sex |'M'==sex) h=(hf+hm)*0.54; else h=(hf*0.923+hm)/2; if(('y'==sports |'Y'==sports)&&('y'==diet |'Y'==diet)) h=(1+0.02+0.015)*h; else if('y'==sports |'Y'==sports) h=(1+0.02)*h; else if('y'==diet |'Y'==diet) h=(1+0.015)*h; else h=h; printf("The height of the boy is %f\n",h);}

匿名用户   2015-04-07 18:27
宝宝知道提示您:回答为网友贡献,仅供参考。