三角形判断,用公式对身高预测

img


这该怎么做?


#include<stdio.h>
int main()
{
    int a,b,c;
    printf("请输入三角形的三边a,b,c的值(整数)\n");
    scanf("%d,%d,%d",&a,&b,&c);
    if(a+b<c||a+c<b||b+c<a)
        printf("输入的三边不能构成三角形\n");
    else if(a==b&&b==c)
        printf("输入的三边能构成等边三角形\n");
    else if((a==b)||(a==c)||(b==c))
        printf("输入的三边能构成等腰三角形\n");
    else if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
        printf("输入的三边能构成直角三角形\n");
    else printf("输入的三边能构成普通三角形\n");
    return 0;
}


#include<stdio.h>
main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a+b>c && a+c>b && b+c>a)
if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)
printf("可以构成一个直角三角形.\n");
else if(a==b && a==c)
printf("可以构成一个等边三角形.\n");
else if(a==b||b==c||a==c)
printf("可以构成一个等腰三角形.\n");
else
printf("不能构成三角形.\n");
}
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main() {
    int result = 0;
    float faHeight, moHeight, manHeight, womanHeight;    //变量的声明,父母身高,用户男女身高
    char sex, sports, diet;                              //性别,运动,饮食习惯
    printf("Please enter your gender:F or M\n");
    scanf("%c", &sex);           //输入性别                //输入用户性别
    while (sex != 'M' && sex != 'F') {                   //都性别输入进行判断,是否符合格式
        printf("输入错误,请重新输入:\n");
        fflush(stdin);                                    //不符合,清楚缓存中的数据
        scanf("%c", &sex);                                //重新输入
    }
    fflush(stdin);                                        //清楚缓存中的数据
    printf("Please enter the height of the father and mother\n");
    result = scanf("%f %f", &faHeight, &moHeight);        //输入父母的身高
    while (result != 2) {                                 //根据scanf()的返回值判断输入是否正确
            printf("输入错误请重新输入:\n");
            fflush(stdin);
            result = scanf("%f %f", &faHeight, &moHeight);
 
    }
        fflush(stdin);
        printf("Do you like physical exercise:Y or N\n");
        scanf("%c", &sports);                      //是否喜欢运动
        while (sports != 'Y' && sports != 'N') {      //格式判断
            printf("输入错误,请重新输入:\n");
            fflush(stdin);
            scanf("%c", &sports);
        }
        fflush(stdin);
        printf("Do you have good eating habits:Y or N\n");
        scanf("%c", &diet);                        //是否有良好的饮食习惯
        while (diet != 'Y' && diet != 'N') {        //格式判断
            printf("输入错误,请重新输入:\n");
            fflush(stdin);
            scanf("%c", &diet);
        }
        fflush(stdin);
        manHeight = (faHeight + moHeight) * (0.54);       //计算男性身高
        womanHeight = (faHeight * (0.923) + moHeight) / 2;  //计算女性身高
        if (sports == 'Y') {                                //是否喜欢运动
            manHeight = manHeight * (1 + 0.02);
            womanHeight = womanHeight * (1 + 0.02);
            if (diet == 'Y') {                             //是否有良好的饮食习惯
                manHeight = manHeight * (1 + 0.015);
                womanHeight = womanHeight * (1 + 0.015);
            }
        }
        if (sex == 'F') {                               //输入判断时男性或者女性用户
            printf("Your height is %f cm", manHeight);
        } else {
            printf("Your height is %f cm", womanHeight);
        }
        return 0;
    }