题解 | #三角形判断#
三角形判断
http://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65
import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNextLine()) {
String inStrs = scan.nextLine();
String[] strs = inStrs.split(" ");
double[] strDoub = new double[3];
for(int i = 0; i < 3; i++) {
strDoub[i] = Double.parseDouble(strs[i]);
}
Arrays.sort(strDoub);
if(strDoub[0] + strDoub[1] <= strDoub[2]) {//不能构成三角形
System.out.println("Not a triangle!");
} else if(strDoub[0] == strDoub[1] && strDoub[1] == strDoub[2]) {//等边三角形
System.out.println("Equilateral triangle!");
} else if(strDoub[0] == strDoub[1] || strDoub[1] == strDoub[2]) {//等腰三角形
System.out.println("Isosceles triangle!");
} else {//普通三角形
System.out.println("Ordinary triangle!");
}
}
}
}