[Cpp]
# Include <iostream>
# Include <cstring>
# Include <cmath>
# Include <algorithm>
Using namespace std;
Struct point
{
Int x, y;
};
Int xj (point x1, point x2, point x3, point x4) // intersection is 1, not 0
{
If (min (x1.x, x2.x)> max (x3.x, x4.x) | min (x1.y, x2.y)> max (x3.y, x4.y)
| Min (x3.x, x4.x)> max (x1.x, x2.x) | min (x3.y, x4.y)> max (x1.y, x2.y)
)
Return 0; // do not submit: the rectangle is excluded from the experiment. The smallest value is greater than the maximum value.
Int a, B, c, d;
A = (x1.x-x2.x) * (x3.y-x1.y)-(x1.y-x2.y) * (x3.x-x1.x); // Cross-Site Experiment
B = (x1.x-x2.x) * (x4.y-x1.y)-(x1.y-x2.y) * (x4.x-x1.x );
C = (x3.x-x4.x) * (x1.y-x3.y)-(x3.y-x4.y) * (x1.x-x3.x );
D = (x3.x-x4.x) * (x2.y-x3.y)-(x3.y-x4.y) * (x2.x-x3.x );
Return a * B <= 0 & c * d <= 0;
}
Int main (void)
{
Int t;
Point x1, x2, j1, j2, j3, j4;
Cin> t;
While (t --)
{
Cin> x1.x> x1.y> x2.x> x2.y> j1.x> j1.y> j3.x> j3.y;
J2.x = j1.x; j2.y = j3.y;
J4.x = j3.x; j4.y = j1.y;
If (min (x1.x, x2.x)> min (j1.x, j3.x) & max (x1.x, x2.x) <max (j1.x, j3.x )&&
Min (x1.y, x2.y)> min (j1.y, j3.y) & max (x1.y, x2.y) <max (j1.y, j3.y ))
{Cout <"T" <endl; continue ;}// determines whether the data is in the internal directory.
If (xj (x1, x2, j1, j2) | xj (x1, x2, j2, j3) | xj (x1, x2, j3, j4) | xj (x1, x2, j4, j1 ))
Cout <"T" <endl; // if one side is intersecting
Else cout <"F" <endl;
}
Author: liang5630