题目:http://acm.hdu.edu.cn/showproblem.php?pid=2056
题目大意就是,给出两个矩形的相对顶点的坐标。求出两个矩形相交的部分的面积。
代码:
#include<cstdio>
#include<iostream>
using namespace std;
int main(){double x1,y1,x2,y2;//矩形1double x3,y3,x4,y4;//矩形2double n1,n2,m1,m2;while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){n1=min(max(x1,x2),max(x3,x4));m1=min(max(y1,y2),max(y3,y4));n2=max(min(x1,x2),min(x3,x4));m2=max(min(y1,y2),min(y3,y4));if(n1>n2&&m1>m2){printf("%.2lf\n",(n1-n2)*(m1-m2));}else{printf("0.00\n");}}
}