题解 | #三角形判断#
三角形判断
http://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65
import java.util.Scanner;
// 三角形的定义
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
// 是否可以构成三角形,任意两条边之和大于第三条边
if (a + b > c && a + c > b && b + c > a) {
if (a == b && b == c) {
System.out.println("Equilateral triangle!");
} else if (a == b || a == c || b == c) {
System.out.println("Isosceles triangle!");
} else {
System.out.println("Ordinary triangle!");
}
} else {
System.out.println("Not a triangle!");
}
}
}
}