用Dev-Cpp寫出下列題目?

Attachment image

1 個解答

評分
  • 1 年前
    最佳解答

    #include<stdio.h>

    #include<stdlib.h>

    main(){

    float man,woman;

    int height,gender,weight;

    printf("Please key in your height: \n");

    scanf("%d",&height);

    printf("Please key in your weight: \n");

    scanf("%d",&weight);

    man = (height-170)*0.6+62;

    woman = (height-158)*0.5+52;

    printf("Please select your gender, man---> 1 ,woman---> 2 \n");

    scanf("%d",&gender);

    if(gender==1)

    {

    printf("Your ideal weight is %.1f\n",man);

    if(weight>man)

    printf("I'm a man. I'm too heavy");

    else

    printf("You are great");

    }

    else if(gender==2)

    {

    printf("Your ideal weight is %f\n",woman);

    if(weight>woman)

    printf("I'm a woman. I'm too heavy");

    else

    printf("You are great");

    }

    else

    printf("invalid gender");

    return 0;

    }

還有問題?馬上發問,尋求解答。