AcWing 3203. 画图
原题链接
简单
作者:
苍茫得胖帅
,
2021-03-16 10:24:47
,
所有人可见
,
阅读 358
重要思想 利用一个二维数组记录是否图上了颜色
C++ 代码
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 110;
bool map[N][N];
int main()
{
int n,x1,x2,y1,y2;
cin >> n;
while(n--)//循环n次
{
cin >> x1 >> y1 >> x2 >> y2;
for(int i = x1;i < x2;i++)
{
for(int j = y1;j < y2;j++)
{
map[i][j] = true;//c++中true小写
}
}
}
int res = 0;
for(int i = 0;i < N;i++)
{
for(int j = 0;j < N;j++)
{
res += (map[i][j] == true);//c++中true小写
}
}
cout << res << endl;
return 0;
}