解题思路:
注意事项:
参考代码:
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
@SuppressWarnings("null")
public static void main(String[] args){
double[] x = new double[4];
double[] y = new double[4];
double[] x1 = new double[4];
double[] y1 = new double[4];
DecimalFormat df = new DecimalFormat("0.00");
Scanner scanner=new Scanner(System.in);
for(int i=0;i<4;i++) {
x[i]=scanner.nextDouble();
y[i]=scanner.nextDouble();
}
x1[0]=Math.max(Math.min(x[0], x[1]), Math.min(x[2], x[3]));
x1[1]=Math.min(Math.max(x[0], x[1]), Math.max(x[2], x[3]));
y1[0]=Math.min(Math.max(y[0], y[1]), Math.max(y[2], y[3]));
y1[1]=Math.max(Math.min(y[0], y[1]), Math.min(y[2], y[3]));
if(x1[1]>x1[0]&&y1[0]>y1[1])
System.out.print(df.format((x1[1]-x1[0])*(y1[0]-y1[1])));
else
System.out.print(df.format(0));
}
}
0.0分
0 人评分