#include<stdio.h>
int main()
{
int sex, sports, diet;
double myheight=0, faheight, moheight;
printf("请输入你的性别(男1/女0)\n你父亲的身高\n你母亲的身高\n是否爱锻炼(是1/不是0)\n是否有好的饮食习惯(有1/没有0)\n");
scanf_s("%d%lf%lf%d%d", &sex, &faheight, &moheight, &sports, &diet);
switch (sex)
{
case 1:
{
if (sports == 1 && diet == 1)
myheight = (faheight + moheight) * 0.54 * 1.035;
if (sports == 1 && diet == 0)
myheight = (faheight + moheight) * 0.54 * 1.02;
if (sports == 0 && diet == 1)
myheight = (faheight + moheight) * 0.54 * 1.015;
if (sports == 0 && diet == 0)
myheight = (faheight + moheight) * 0.54;
printf("你的身高可能是:%5.2f cm", myheight); break;
}
case 0:
{
if (sports == 1 && diet == 1)
myheight = (faheight * 0.923 + moheight) / 2 * 1.035;
if (sports == 1 && diet == 0)
myheight = (faheight * 0.923 + moheight) / 2 * 1.02;
if (sports == 0 && diet == 1)
myheight = (faheight * 0.923 + moheight) / 2 * 1.015;
if (sports == 0 && diet == 0)
myheight = (faheight * 0.923 + moheight) / 2;
printf("你的身高可能是:%5.2f cm", myheight); break;
}
}
}
【C熟肉】据父母身高及自己习惯判断身高
最新推荐文章于 2024-05-06 21:19:16 发布