NOJ1013 三角形判断

#include
#include

int main()
{
    double a = -1, b = -1, c = -1;
    while (a != 0 && b != 0 && c != 0)
    {
        scanf("%lf %lf %lf", &a, &b, &c);
        if (a ==0&& b ==0&& c == 0)
            break;
        if (a + b > c && a + c > b && b + c > a)
        {
            if (a == b && b == c && a == c)
                printf("Equilateral triangle\n");
            else if (fabs(a * a + b * b - c * c) < 0.001 || fabs(a * a + c * c - b * b) < 0.001 || fabs(c * c + b * b - a * a) < 0.001)
            {
                if (a == b || b == c || a == c)
                    printf("Isosceles right triangle\n");
                else
                    printf("Right triangle\n");
            }
            else if (a == b || b == c || a == c)
                printf("Isosceles triangle\n");
            else
                printf("General triangle\n");
        }
        else
            printf("Not a triangle\n");
    }
    printf("End");
    return 0;
}

NOJ1013 三角形判断》有1个想法

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注