解题思路:
注意事项:
参考代码:#include
int main(){
double a1,a2,b1,b2,c1,c2,d1,d2,e1,e2,f1,f2;
scanf("%lf %lf %lf %lf",&a1,&a2,&b1,&b2);
scanf("%lf %lf %lf %lf",&c1,&c2,&d1,&d2);
//求出两矩形左下和右上两个点坐标
if(a2>b2){double t=b2;b2=a2;a2=t;}
if(c2>d2){double t=d2;d2=c2;c2=t;}
if(a1>b1){double t=b1;b1=a1;a1=t;}
if(c1>d1){double t=d1;d1=c1;c1=t;}
//无交集
if(a1>=d1||a2>=d2||b1<=c1||b2<=c2)printf("0.00");
//求重合矩形的左下和右上两点坐标
else{
e1=a1>=c1?a1:c1;
e2=a2>=c2?a2:c2;
f1=b1<=d1?b1:d1;
f2=b2<=d2?b2:d2;
printf("%.2f",(f1-e1)*(f2-e2));
}
}