思路:
因为是在第一象限,首先需要确定,length,width都大于0,在输入的时候就直接计算它的面积,利用max函数和min函数。
代码如下:
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int length,width;
int main()
{
cin>>n>>a>>b;
int x1,y1,x2,y2;
int sum=0;
for(int i=0;i<n;i++){
cin>>x1>>y1>>x2>>y2;
length=min(a,x2)-max(0,x1);
width=min(b,y2)-max(0,y1);
if(length>=0&&width>=0){
sum+=length*width;
}
}
cout<<sum;
return 0;
}