package com.demo3;
import java.util.Scanner;
/*
* Given two rectangles(矩形) and the coordinates(坐标) of two points
* on the diagonals(对角线) of each rectangle,
* you have to calculate(计算) the area of the intersected(分割) part of two rectangles.
* its sides are parallel(平行) to OX and OY .
*
* 给出两个矩形的对角线上的两点
* 然后求出两个矩形想交的面积。
*/
public class HDU_oj2056 {
public static void main(String[] args) {
Scanner sn = new Scanner(System.in);
while (sn.hasNext()) {
// 第一个矩形对角线上的两点
double a1 = sn.nextDouble();
double b1 = sn.nextDouble();
double a2 = sn.nextDouble();
double b2 = sn.nextDouble();
// 第二个矩形对角线上的两点
double c1 = sn.nextDouble();
double d1 = sn.nextDouble();
double c2 = sn.nextDouble();
double d2 = sn.nextDouble();
double k = 0, a, b, c, d; // 统统交换成前一个小,后一个大,的正比例函数方向的对角线
if (a1 > a2) {
k = a1;
a1 = a2;
a2 = k;
}
if (b1 > b2) {
k = b1;
b1 = b2;
b2 = k;
}
if (c1 > c2) {
k = c1;
c1 = c2;
c2 = k;
}
if (d1 > d2) {
k = d1;
d1 = d2;
d2 = k;
}
// 在x方向的比较
// 在y反向的比较
if (a1 > c2 || a2 < c1 || b1 > d2 || b2 < d1) {// 判断是否相离
System.out.println("0.00");
} else { // 两个矩形有相交部分
if (a1 <= c1)
a = c1;
else
a = a1;
if (a2 <= c2)
b = a2;
else
b = c2;
if (b1 <= d1)
c = d1;
else
c = b1;
if (b2 <= d2)
d = b2;
else
d = d2;
System.out.println(String.format("%.2f", (b - a) * (d - c)));
}
}
sn.close();
}
}