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;
}
杭电oj —— 2056(求两个矩形相交部分面积)
最新推荐文章于 2022-12-28 17:51:27 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)