1 #include<iostream> 2 using namespace std; 3 void input(int x1, int y1, int x2, int y2,int a[100][100]) //給數組賦值(染色) 4 { 5 for (int i = x1; i < x2; i++) 6 { 7 for (int j = y1; j < y2; j++) 8 a[i][j]++; 9 } 10 } 11 12 int main() 13 { 14 static int a[100][100]; 15 int n, x1, y1, x2, y2; 16 cin >> n; 17 for (int i = 0; i < n; i++) 18 { 19 cin >> x1 >> y1 >> x2 >> y2; 20 input(x1, y1, x2, y2, a); 21 } 22 n = 0; 23 //檢索不為0的數目 24 for (int i = 0; i < 100; i++) 25 { 26 for (int j = 0; j < 100; j++) 27 { 28 if (a[i][j] != 0) 29 n++; 30 } 31 } 32 cout << n << endl; 33 system("pause"); 34 return 0; 35 }