Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- using namespace std;
- struct point { double x, y; };
- // Читать координаты точки
- struct point get()
- {
- struct point a;
- cin >> a.x;
- cin >> a.y;
- return a;
- }
- // Вычисляет положение точки D(xd,yd) относительно прямой AB
- double g(struct point a, struct point b, struct point d)
- {
- return (d.x - a.x) * (b.y - a.y) - (d.y - a.y) * (b.x - a.x);
- }
- // Лежат ли точки C и D с одной стороны прямой (AB)?
- bool f(struct point a, struct point b, struct point c, struct point d)
- {
- return g(a, b, c) * g(a, b, d) >= 0;
- }
- int main()
- {
- setlocale(LC_ALL, "Rus");
- struct point a = get(), b = get(), c = get(), d = get();
- cout << (f(a, b, c, d) && f(b, c, a, d) && f(c, a, b, d) ? "yes" : "no") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment