![在这里插入图片描述 P2956 [USACO09OCT]The Robot Plow G 机器人耕地_i++](https://file.cfanz.cn/uploads/png/2022/07/28/11/1c73JXf2eD.png)
![在这里插入图片描述 P2956 [USACO09OCT]The Robot Plow G 机器人耕地_c语言_02](https://file.cfanz.cn/uploads/png/2022/07/28/11/3N30We4OD6.png)
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int x, y, num, x1, y1, x2, y2, cnt = 0;
scanf("%d %d %d", &x, &y, &num);
int sign[x][y], i, j;
for ( i = 0; i < x; i++)
for ( j = 0; j < y; j++)
sign[i][j] = 0;
while(num){
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
for ( i = x1 - 1; i <= x2 - 1; i++)
for ( j = y1 - 1; j <= y2 - 1; j++)
sign[i][j] = 1;
num--;
}
for (i = 0; i < x; i++)
for ( j = 0; j < y; j++){
if ( sign[i][j] == 1)
cnt++;
}
printf("%d", cnt);
return 0;
}
也就是标记数组做标记,只不过成了二维数组。










