题解 | #三角形判断#
三角形判断
https://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65
#include <stdio.h>
/*
三角形判断:任意两边之和大于第三边(任意两边只差小于第三边)
参数表: a,b,c 分别对应三角形的三边
*/
void IsTriangle(double a, double b, double c)
{
if(a+b > c && a+c > b && b+c > a){
//判断是否为三角形
if (a == b && a == c) {
//判断是否为等边三角形
printf("Equilateral triangle!");
}else if(a == b || a == c || b == c){
//判断是否为等腰三角形
printf("Isosceles triangle!\n");
}else {
//都不是则为普通三角形
printf("Ordinary triangle!");
}
}else{
printf("Not a triangle!");
}
}
int main() {
int a = 0;
int b = 0;
int c = 0;
while(scanf("%d %d %d", &a, &b, &c) == 3){
IsTriangle(a, b, c);
}
return 0;
}
腾讯云智研发成长空间 2798人发布