身高预测
1 #include<stdio.h> 2 int main() 3 { 4 char sex,sports,diet; 5 float faheight,moheight,height; 6 printf("请输入父亲身高:"); 7 scanf("%f",&faheight); 8 printf("请输入母亲身高: "); 9 scanf("%f",&moheight); 10 printf("是否喜爱运动(Y/N):"); 11 scanf(" %c",&sports); 12 printf("是否有良好的饮食习惯(Y/N):"); 13 scanf(" %c",&diet); 14 printf("请输入性别(F/M):"); 15 scanf(" %c",&sex); 16 if(sex=='F') 17 { 18 height=(faheight*0.923+moheight)/2; 19 if(sports=='Y'&&diet=='Y') 20 height=height*(1+0.035); 21 else if(diet=='Y') 22 height=height*(1+0.015); 23 else if(sports=='Y') 24 height=height*(1+0.02); 25 } 26 else if(sex=='M') 27 { 28 height=(faheight+moheight)*0.54; 29 height=(faheight*0.923+moheight)/2; 30 if(sports=='Y'&&diet=='Y') 31 height=height*(1+0.035); 32 else if(diet=='Y') 33 height=height*(1+0.015); 34 else if(sports=='Y') 35 height=height*(1+0.02); 36 } 37 printf("预测的身高为:%5.2fcm\n",height); 38 return 0; 39 }