身高预测系统

黄老师 实验报告五 1

#include <stdio.h>
#include <stdlib.h>

enum Sex
{
    Female = 1,
    Male
};
typedef struct Input_In
{
    enum Sex sex;
    char name[20];
    unsigned int Height[3];
} Informa;

void Print_Show(void);
void Informa_Gain(Informa *ptr_i);
void Forecast(Informa *ptr_i);

int main(void)
{
    Informa *informa;
    informa = (Informa *)malloc(sizeof(Informa));

    Print_Show();
    Informa_Gain(informa);
    Forecast(informa);
    free(informa);

    system("pause");
    return 0;
}

void Print_Show(void)
{
    printf("*******************************************\n\
* Welcome to Use Height Prediction System *\n\
*******************************************\n\
Please choose the sex:\n1.Female\n2.Male\n");
}

void Informa_Gain(Informa *ptr_i)
{
    Informa *p = ptr_i;
    int sex_temp;

    printf("Your choice is: ");
    scanf("%d", &sex_temp);
    fflush(stdin);
    p->sex = (enum Sex)sex_temp;
    printf("May I know your Surname? ");
    scanf("%s", p->name);
    fflush(stdin);
    printf("Hi, Miss %s!\n", p->name);
    printf("Could you please input your mother's height(cm): ");
    scanf("%d", &p->Height[0]);
    fflush(stdin);
    printf("Could you please input your father's height(cm): ");
    scanf("%d", &p->Height[1]);
}

void Forecast(Informa *ptr_i)
{
    Informa *p = ptr_i;

    switch (ptr_i->sex)
    {
    case Female:
        p->Height[2] = (p->Height[1] * 0.923 + p->Height[0]) / 2;
        break;
    case Male:
        p->Height[2] = (p->Height[1] + p->Height[0]) * 0.54;
        break;
    default:
        break;
    }
    printf("Your predicted height is %dcm\n", p->Height[2]);
    printf("Thank you for use our “Height Prediction System”!\n");
}

  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_64248798

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值