题解 | #三角形判断#
三角形判断
https://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65
#include <stdio.h>
int main() {
int a = 0;
int b = 0;
int c = 0;
while (scanf("%d %d %d", &a, &b, &c) != EOF) {
//将三边从小到大排序
int tmp = 0;
if (a > b) {
tmp = a;
a = b;
b = tmp;
}
if (a > c) {
tmp = a;
a = c;
c = tmp;
}
if (b > c) {
tmp = b;
b = c;
c = tmp;
}
if (a + b > c) {//判断是否构成三角形
if (a == b || b == c || a == c) {//判断是否等腰
if (a == b && b == c)//判断是否等边
printf("Equilateral triangle!\n");
else
printf("Isosceles triangle!\n");
}
else
printf("Ordinary triangle!\n");
}
else
printf("Not a triangle!\n");
}
return 0;
}