题解 | #三角形判断#

三角形判断

https://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65

#include <stdio.h>
int main() {
    int a = 0, b = 0, c = 0;
    int  t = 0;
    while (scanf("%d %d %d", &a, &b, &c) != EOF) {
        if (a < b) {    //将三边排序 a > b > c
            t = a;
            a = b ;
            b = t;
        }
        if (a < c) {
            t = a;
            a = c;
            c = t;
        }
        if (b < c) {
            t = b;
            b = c ;
            c = t;
        }
        if (a<b+c) {    //三角形判定定理:任意两边之和大于第三边 -->  a<b+c
            if (a==b&&a==c&&b==c) {  //等边
             printf("Equilateral triangle!\n");
            } else if (a==b||a==c||b==c) { 
			 printf("Isosceles triangle!\n");  //等腰
            } else {
             printf("Ordinary triangle!\n");  //普通
            }
        
        } else {
        printf("Not a triangle!\n"); //非三角形
        }

    }
    return 0;
}

全部评论

相关推荐

06-19 19:06
门头沟学院 Java
码农索隆:别去东软,真学不到东西,真事
点赞 评论 收藏
分享
强大的马里奥:不太可能,我校计算机硕士就业率99%
点赞 评论 收藏
分享
不亏是提前批,神仙打架,鼠鼠不配了
站队站对牛:现在92都报工艺岗了
投递韶音科技等公司7个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务