文章目录
- C++
- 总结
本题链接:201409-2 画图
本博客给出本题截图:
C++
#include <iostream> using namespace std; const int N = 110; int st[N][N]; int main() { int n; cin >> n; int x1, y1, x2, y2; for (int i = 0; i < n; i ++ ) { cin >> x1 >> y1 >> x2 >> y2; for (int i = x1; i < x2; i ++ ) for (int j = y1; j < y2; j ++ ) st[i][j] = 1; } int res = 0; for (int i = 0; i < N; i ++ ) for (int j = 0; j < N; j ++ ) res += st[i][j]; cout << res << endl; return 0; }
总结
每个格子用其左下角坐标代表
后续会给出一个 扫描线 版本的代码,预计2021.12.31
之前