-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_3.java
More file actions
36 lines (30 loc) · 1017 Bytes
/
Copy pathMain_3.java
File metadata and controls
36 lines (30 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package synap_3;
public class Main_3 {
public static void main(String[] args) {
int[][] rectangles = { { 1, 0, 4, 2 }, { 8, 3, 9, 4 }, { 2, 3, 5, 7 }, { 4, 6, 7, 8 }, { 3, 1, 6, 5 },
{ 1, 8, 4, 10 }, { 7, 2, 9, 5 }, { 8, 8, 10, 9 }, { 1, 4, 2, 6 } };
int[][] screen = new int[1920][1080];
for (int[] rectangle : rectangles) {
int leftTopX = rectangle[0];
int leftTopY = rectangle[1];
int rightBottomX = rectangle[2];
int rightBottomY = rectangle[3];
// 사각형이 차지하는 부분을 1로 표시
for (int i = leftTopX; i < rightBottomX; i++) {
for (int j = leftTopY; j < rightBottomY; j++) {
screen[i][j] = 1;
}
}
}
// 전체 면적 계산
int totalArea = 0;
for (int i = 0; i < screen.length; i++) {
for (int j = 0; j < screen[i].length; j++) {
if (screen[i][j] == 1) {
totalArea++;
}
}
}
System.out.println("화면에서 직사각형들이 차지하고 있는 총면적: " + totalArea);
}
}