#include<iostream> #include<math.h> #include<algorithm> #include<stdlib.h> #include<iomanip> using namespace std; int Comp(const void*a,const void*b){ return *(double*)a-*(double*)b; } void main(){ double x1,y1,x2,y2,x3,y3,x4,y4; double x[4]; double y[4]; while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){ x[0]=x1;y[0]=y1; x[1]=x2;y[1]=y2; x[2]=x3;y[2]=y3; x[3]=x4;y[3]=y4; double Zero=0.00; qsort(x,4,sizeof(x[0]),Comp); qsort(y,4,sizeof(y[0]),Comp); double l=fabs(x2-x1)+fabs(x4-x3)-fabs(x[3]-x[0]); double h=fabs(y2-y1)+fabs(y4-y3)-fabs(y[3]-y[0]); if(l<=0||h<=0) cout<<setprecision(2)<<fixed<<Zero<<endl; else { double s=l*h; cout<<setprecision(2)<<fixed<<s<<endl; } } }
杭电ACM 第2056题
最新推荐文章于 2021-02-22 13:27:17 发布