Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (21 sloc) 850 Bytes
package lesson3;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Введите координату Х");
double x = scan.nextDouble();
System.out.println("Введите координату Y");
double y = scan.nextDouble();
double first = (0 - x) * (4 - 0) - (4 - 0) * (0 - y);
double second = (4 - x) * (1 - 4) - (6 - 4) * (4 - y);
double third = (6 - x) * (0 - 1) - (0 - 6) * (1 - y);
if (first >= 0 & second >= 0 & third >= 0) {
System.out.println("Точка внутри треугольника");
} else if (first <= 0 & second <= 0 & third <= 0) {
System.out.println("Точка внутри треугольника");
} else {
System.out.println("Точка внe треугольника");
}
}
}
You can’t perform that action at this time.