import java.util.Arrays;
import java.util.Scanner;
import java.util.prefs.BackingStoreException;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double x1 = sc.nextDouble();
double y1 = sc.nextDouble();
double x2 = sc.nextDouble();
double y2 = sc.nextDouble();
double x3 = sc.nextDouble();
double y3 = sc.nextDouble();
double x4 = sc.nextDouble();
double y4 = sc.nextDouble();
//求相交区域的右上角坐标
double n1 = Math.min(Math.max(x1, x2), Math.max(x3, x4));
double m1 = Math.min(Math.max(y1, y2), Math.max(y3, y4));
//求相交区域的左下角坐标
double n2 = Math.max(Math.min(x1, x2), Math.min(x3, x4));
double m2 = Math.max(Math.min(y1, y2), Math.min(y3, y4));
//求相交矩形的面积
double s = 0.0;
if(n1 <= n2 ||m1 <= m2){//不存在交的情况
System.out.printf("%.2f", s);
}else{
s = Math.abs(n1-n2)*Math.abs(m1-m2);
System.out.printf("%.2f", s);
}
}
}
矩形面积交
最新推荐文章于 2019-09-18 08:28:57 发布