#include<stdio.h>
#include<math.h>
int x, y;
int s[2005][2005];
struct
{
int x1, x2, y1, y2;
}site[20];
int seat;
int min(int x, int y)
{
if (x < y)return x;
else return y;
}
int main()
{
for (int i = 1; i <= 3; i++)
{
scanf("%d %d %d %d", &site[i].x1, &site[i].y1, &site[i].x2, &site[i].y2);
if (site[i].x1 < 0 )
x = min(x, site[i].x1);
if (site[i].y1 < 0 )
y = min(y, site[i].y1);
}
for (int i = 1; i <= 3; i++)
{
site[i].x1 -= x, site[i].x2 -= x;
site[i].y1 -= y, site[i].y2 -= y;
}//存在x或者y小于0 的情况,这样的情况不方便放入数组,因此将其整体向右向上位移,x,y为位移的大小
//printf("%d %d\n", x, y);
/*for (int i = 1; i <= 3; i++)
printf("%d %d %d %d\n", &site[i].x1, &site[i].y1, &site[i].x2, &site[i].y2);
*/
for (int i = site[3].x1; i < site[3].x2; i++)
for (int j = site[3].y1; j < site[3].y2; j++)
s[i][j] = 1;//在数组中将汽车位置储存,
for(int l = 1; l <= 2; l++)
for(int i = site[l].x1; i < site[l].x2; i++)
for (int j = site[l].y1; j < site[l].y2; j++)
{
if (s[i][j] == 1)continue;
else if (s[i][j] == 2) continue;//存在两个广告牌在一起的情况,跳过
s[i][j] = 2;
seat++;
}
/*for (int i = 0; i <= 10; i++)
{
for (int j = 0; j <= 10; j++)
printf("%d ", s[i][j]);
printf("\n");
}
*/
printf("%d", seat);
return 0;
}
08-18
352
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)