Пересечение отрезков
#include <iostream>
#include <algorithm>
using namespace std;
struct point {
int x,y;
point() {}
point(int x, int y):x(x),y(y) {}
point operator-(point p) const
{ return point(x-p.x,y-p.y);
}
int operator^(point p) const
{ return x*p.y-y*p.x;
}
friend istream& operator>>(istream &in, point &p)
{ return in>>p.x>>p.y;
}
} p1,p2,p3,p4;
int sign(int a)
{ return a==0?0:(a<0?-1:1);
}
int main()
{
cin>>p1>>p2>>p3>>p4;
cout<<(max(min(p1.x,p2.x),min(p3.x,p4.x)) <= min(max(p1.x,p2.x),max(p3.x,p4.x)) &&
max(min(p1.y,p2.y),min(p3.y,p4.y)) <= min(max(p1.y,p2.y),max(p3.y,p4.y)) &&
sign((p3-p1)^(p2-p1))*sign((p4-p1)^(p2-p1))<=0 &&
sign((p1-p3)^(p4-p3))*sign((p2-p3)^(p4-p3))<=0)?
"Yes\n":"No\n");
return 0;
}