#include<iostream>
#include<iomanip>
using namespace std;
int main(){
double m1, n1, m2, n2, a1, b1, a2, b2, d1=0, d2=0;
cin>>m1>>n1>>m2>>n2>>a1>>b1>>a2>>b2;
if(m1>m2) swap(m1, m2);
if(n1>n2) swap(n1, n2);
if(a1>a2) swap(a1, a2);
if(b1>b2) swap(b1, b2);
if(a1>=m1&&a1<=m2){ //a1在吗m1和m2之间
if(a2<=m2) d1=a2-a1;
else if(a2>m2) d1=m2-a1;
}else if(a1<m1){
if(a2<m1) d1=0;
else if(a2<=m2&&a2>=m1) d1=a2-m1;
else if(a2>m2) d1=m2-m1;
}
if(b1>=n1&&b1<=n2){ //a1在吗m1和m2之间
if(b2<=n2) d2=b2-b1;
else if(b2>n2) d2=n2-b1;
}else if(b1<n1){
if(b2<n1) d2=0;
else if(b2<=n2&&b2>=n1) d2=b2-n1;
else if(b2>n2) d2=n2-n1;
}
double s=d1*d2;
cout<<fixed<<setprecision(2)<<s<<endl;
return 0;
}
原文地址:https://www.cnblogs.com/A-Little-Nut/p/10352774.html
时间: 2024-10-21 03:52:05