привет! найди ошибку x1 = int(input()) y1 = int(input()) x2 = int(input()) y2 =…
- User
привет! найди ошибку
x_1 = int(input()) y_1 = int(input()) x_2 = int(input()) y_2 = int(input()) x = int(input()) y = int(input())
посчитаем коэффициенты k и b прямой (диагонали)
b = (y_1 - y_2 * x_1 / x_2 ) / (1 - x_1 / x_2) k = (y_2 - b) / x_2
расстояния от точки до вершин
from_x_y_to_x_1_y_1 = ((x_1 - x)^2 + (y_1 - y)^2)**1/2 from_x_y_to_x_2_y_2 = ((x_2 - x)^2 + (y_2 - y)^2)**1/2 from_x_y_to_x_1_y_2 = ((x_1 - x)^2 + (y_2 - y)^2)**1/2 from_x_y_to_x_2_y_1 = ((x_2 - x)^2 + (y_1 - y)^2)**1/2
min_route = min(from_x_y_to_x_1_y_1, from_x_y_to_x_1_y_2, from_x_y_to_x_2_y_1, from_x_y_to_x_2_y_2)
if y == k * x + b: if min_route == from_x_y_to_x_1_y_1: print('SW') if min_route == from_x_y_to_x_2_y_2: print('NE') if min_route == from_x_y_to_x_1_y_2: print('NW') if min_route == from_x_y_to_x_2_y_1: print('SE')
else: if y > k * x + b and y < - k * x + b: min_route = min(from_x_y_to_x_1_y_1, from_x_y_to_x_1_y_2, x - x_1) if min_route == x - x_1: print('W') if min_route == from_x_y_to_x_1_y_1: print('SW') if min_route == from_x_y_to_x_1_y_2: print('NW') if y > k * x + b and y > - k * x + b: min_route = min(from_x_y_to_x_1_y_2, from_x_y_to_x_2_y_2, y - y_2) if min_route == y - y_2: print('N') if min_route == from_x_y_to_x_2_y_2: print('NE') if min_route == from_x_y_to_x_1_y_2: print('NW') if y < k * x + b and y > - k * x + b: min_route = min(from_x_y_to_x_2_y_2, from_x_y_to_x_2_y_1, x - x_2) if min_route == x - x_2: print('E') if min_route == from_x_y_to_x_2_y_2: print('NE') if min_route == from_x_y_to_x_2_y_1: print('SE') if y < k * x + b and y < - k * x + b: min_route = min(from_x_y_to_x_1_y_1, from_x_y_to_x_2_y_1, y - y_1) if min_route == y - y_1: print('S') if min_route == from_x_y_to_x_1_y_1: print('SW') if min_route == from_x_y_to_x_2_y_1: print('SE')
- Assistant