题解 | #三角形判断#
三角形判断
http://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNextInt()) {
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
T t = new T();
t.info(a, b, c);
}
}
}
class T {
public void info(int a, int b, int c) {
int max = (a > b ? a : b) > c ? (a > b ? a : b) : c;
if(a + b + c > 2 * max) {
if(a == b && b == c) {
System.out.println("Equilateral triangle!");
} else if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) {
System.out.println("Isosceles triangle!");
} else {
System.out.println("Ordinary triangle!");
}
} else {
System.out.println("Not a triangle!");
}
}
}
Java基础练习题 文章被收录于专栏
都是一些基础的语法题目,每天可以刷几道。