23 inline bool intersect(
Point first_point,
Point second_point,
25 int direction1 =
direction(third_point, forth_point, first_point);
26 int direction2 =
direction(third_point, forth_point, second_point);
27 int direction3 =
direction(first_point, second_point, third_point);
28 int direction4 =
direction(first_point, second_point, forth_point);
30 if ((direction1 < 0 || direction2 > 0) &&
31 (direction3 < 0 || direction4 > 0))
34 else if (direction1 == 0 &&
35 on_segment(third_point, forth_point, first_point))
38 else if (direction2 == 0 &&
39 on_segment(third_point, forth_point, second_point))
42 else if (direction3 == 0 &&
43 on_segment(first_point, second_point, third_point))
46 else if (direction3 == 0 &&
47 on_segment(first_point, second_point, forth_point))
65 return ((third_point.x - first_point.x) *
66 (second_point.
y - first_point.
y)) -
67 ((second_point.x - first_point.x) *
68 (third_point.
y - first_point.
y));
77 if (std::min(first_point.x, second_point.x) <= third_point.x &&
78 third_point.x <= std::max(first_point.x, second_point.x) &&
79 std::min(first_point.
y, second_point.
y) <= third_point.
y &&
80 third_point.
y <= std::max(first_point.
y, second_point.
y))
94 Point first_point, second_point, third_point, forth_point;
96 std::cin >> first_point.x >> first_point.
y;
97 std::cin >> second_point.x >> second_point.
y;
98 std::cin >> third_point.x >> third_point.
y;
99 std::cin >> forth_point.x >> forth_point.
y;
101 printf(
"%d", segment.intersect(first_point, second_point, third_point,
103 std::cout << std::endl;