Skip to content

Instantly share code, notes, and snippets.

@StrixG
Created October 18, 2015 15:18
Show Gist options
  • Save StrixG/93147f2c92aca493bbf5 to your computer and use it in GitHub Desktop.
Save StrixG/93147f2c92aca493bbf5 to your computer and use it in GitHub Desktop.
Тип треугольника
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] sides = {in.nextInt(), in.nextInt(), in.nextInt()};
Arrays.sort(sides);
if (sides[0] < sides[1] + sides[2] && sides[1] < sides[0] + sides[2] && sides[2] < sides[0] + sides[1]) {
double legSum = Math.pow(sides[0], 2) + Math.pow(sides[1], 2);
double hypotenuse = Math.pow(sides[2], 2);
if (legSum == hypotenuse) {
System.out.println("right");
} else if (legSum > hypotenuse) {
System.out.println("acute");
} else if (legSum < hypotenuse) {
System.out.println("obtuse");
}
} else {
System.out.println("impossible");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment