C语言——身高预测

    科技2022-07-11  180

    #include “stdafx.h” #include<math.h> int _tmain(int argc, _TCHAR* argv[]) { char sex,sports,diet; double babyHeight,faHeight,moHeight; printf(“Are you a boy(M) or a girl(F)?”); scanf_s(" %c",&sex); printf(“Please input your father’s height(cm):”); scanf_s("%lf",&faHeight); printf(“Please input your mother’s height(cm):”); scanf_s("%lf",&moHeight); printf(“Do you like sports(Y/N)?”); scanf_s(" %c",&sports); printf(“Do you have a good habit of diet(Y/N)?”); scanf_s(" %c",&diet); if(sex==‘M’) babyHeight=(faHeight+moHeight)0.54; else babyHeight=(faHeight0.923+moHeight)/2.0; if(sports==‘Y’) babyHeight=babyHeight+babyHeight0.02; if(diet==‘Y’) babyHeight=babyHeight+babyHeight0.015; printf(“Your future height will be %.2f(cm)\n”,babyHeight); }

    Processed: 0.019, SQL: 8