思路:
确定出相交矩形的四条边即可
这里只举左边的边,其它类似:
左边的边 = 两个矩形的左边的边的较大的
typedef struct
{
int x1, x2;
int y1, y2;
}Tingle;
int main()
{
Tingle t1, t2;
cin >> t1.x1 >> t1.y1 >> t1.x2 >> t1.y2;
cin >> t2.x1 >> t2.y1 >> t2.x2 >> t2.y2;
double a, b, c, d;
a = max(min(t1.x1, t1.x2), min(t2.x1, t2.x2));
b = min(max(t1.x1, t1.x2), max(t2.x1, t2.x2));
c = max(min(t1.y1, t1.y2), min(t2.y1, t2.y2));
d = min(max(t1.y1, t1.y2), max(t2.y1, t2.y2));
if (a < b && c < d) printf("%0.2lf\n", (b - a) * (d - c));
else cout << "0.00" << endl;
return 0;
}