【ACM】杭电OJ 2056

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

const int maxn = 100000;
double a[4],b[4];

int main ()
{
    double l,w,x1,y1,x2,y2,x3,y3,x4,y4,x,y;
    while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)
    {
        a[0]=x1;a[1]=x2;a[2]=x3;a[3]=x4;
        b[0]=y1;b[1]=y2;b[2]=y3;b[3]=y4;
        sort(a,a+4);
        sort(b,b+4);
        l=fabs(x1-x2)+fabs(x3-x4)-(a[3]-a[0]);
        w=fabs(y1-y2)+fabs(y3-y4)-(b[3]-b[0]);
        if(l<0 || w<0)    printf("0.00\n");
        else    printf("%.2lf\n",l*w);
    }
    return 0;
}

 

你可能感兴趣的:(ACM)