1. 程式人生 > >杭電矩形面積交

杭電矩形面積交

 
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[1000]={0};
int main()
{
	int n,i,j,count=0; 
	double x1,x2,x3,x4,y1,y2,y3,y4,a,b,c,d;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)
	{
		a=max(min(x1,x2),min(x3,x4));
		b=min(max(y1,y2),max(y3,y4));
		c=min(max(x1,x2),max(x3,x4));
		d=max(min(y1,y2),min(y3,y4));
		if(a<=c&&b>=d)
		printf("%.2f\n",(c-a)*(b-d));
		else
		printf("0.00\n");
		
	}
	return 0;
}