根据父母身高预测女儿身高C语言代码
#include<stdio.h>
#define DEG 0.923
#define CEG 2
float height(float father,float mother);
int main()//定义主函数//
{
//定义mother father的数据类型//
float father;
float mother;
float daughter;
printf(" \tCaculate daughter's height \n");
printf("****************************************\n");
printf("*****This program write by Pangolin*****\n");
printf("****************************************\n");
printf("Please input father's height :\n");
scanf("%fm",&father);
printf("Please input mother's height :\n");
scanf("%fm",&mother);
daughter = height(father,mother);
printf("Caculate daughter's height :");
printf("%.2fm\n",daughter);
}
float height(float father,float mother)
{
float daughter = (father * DEG + mother)/CEG;
return daughter;
}
运行结果: