C语言 MOOC 身高

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chenyuk1/article/details/71663489
#include <stdio.h>
int main()
{
    int x;
    float m,f,i,r;
    scanf ("%d %f %f %f",&x,&m,&f,&i);
    //if (x==2||x==1)
   // printf("%d %f %f %f\n",x,m,f,i);
    int flag=0;
    switch(x)
    {
        case(1): r=(m+f)*1.08/2;break;
        case(2):r=(f*0.923+m)/2;break;
        default:    printf("输入的性别错误"),flag=1;
        //理解default的用法;
    }
    if(flag)  return 0;

    int shengao=r+0.5;
    //关于四舍五入   float  a =1.9;
    //            int b=a;  // b=1;
    //  float 和double 强制转换 int  都是舍去小数点后的数字
    printf("%d\n",shengao);
    int wucha= r-i>0?r-i:i-r;
    if(wucha<=3)
        printf("符合");
    else
        printf("不符合");

   /* else
        printf("输入的性别错误");
    if ((int)(r*10)%10<=5)
        r=(int)r%1;
    else
        r=(int)r+(int)r%1;
    printf("%d\n",r);
    if ((r-i)<=3&&(r-i)>=(-3))
        printf("符合");
    else
        printf("不符合");
        */

return 0;
}

猜你喜欢

转载自blog.csdn.net/chenyuk1/article/details/71663489