hash直接解决(这大概是做的最简单的第二题了。。)
AC代码:
#include <stdio.h>
#include <math.h>
bool hhash[105][105];
int main(){
for(int i = 0;i <=100;i++){
for(int j = 0;j <= 100;j++){
hhash[i][j] = false;
}
}
int n,cnt = 0;
int x1,y1,x2,y2;
scanf("%d",&n);
for(int i = 0;i <n;i++){
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
for(int j = x1;j < x2;j++){
for(int s = y1;s < y2;s++){
if(hhash[j][s] == false){
cnt++;
hhash[j][s] = true;
}
}
}
}
printf("%d",cnt);
}