cpp
复制代码
#include<iostream>
std::string is(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
int d1, d2, d3, d4;
d1 = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);//向量AB * AC的叉积
d2 = (x2 - x1) * (y4 - y1) - (y2 - y1) * (x4 - x1);//AB * AD
d3 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);//CD * CA
d4 = (x4 - x3) * (y2 - y3) - (y4 - y3) * (x2 - x3);//CD * CB
if (std::max(x1, x2) < std::min(x3, x4) || std::max(x3, x4) < std::min(x1, x2)
|| std::max(y1, y2) < std::min(y3, y4) || std::max(y3, y4) < std::min(y1, y2))
return "no";
else if (d1 * d2 <= 0 && d3 * d4 <= 0)
return "yes";
else
return "no";
}
int main()
{
int x1, y1, x2, y2, x3, y3, x4, y4;
while (std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4)
{
std::cout << is(x1, y1, x2, y2, x3, y3, x4, y4) << std::endl;
}
return 0;
}