forked from sowon-dev/AlgorithmStudy_Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc1098.java
More file actions
51 lines (43 loc) ยท 1.46 KB
/
c1098.java
File metadata and controls
51 lines (43 loc) ยท 1.46 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package codeup100;
import java.util.Scanner;
public class c1098 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//์ฒซ ์ค์ ๊ฒฉ์ํ์ ์ธ๋ก(h), ๊ฐ๋ก(w) ๊ฐ ๊ณต๋ฐฑ์ ๋๊ณ ์
๋ ฅ๋๊ณ ,
int h = sc.nextInt();
int w = sc.nextInt();
int[][] arr = new int[h+1][w+1];
//๋ ๋ฒ์งธ ์ค์ ๋์ ์ ์๋ ๋ง๋์ ๊ฐ์(n)
int n = sc.nextInt(); //3
//์ธ ๋ฒ์งธ ์ค๋ถํฐ ๊ฐ ๋ง๋์ ๊ธธ์ด(l), ๋ฐฉํฅ(d), ์ขํ(x, y)๊ฐ ์
๋ ฅ๋๋ค.
// 2 0 1 1
// 3 1 2 3
// 4 1 2 5
for(int a=0; a<n; a++){
int l = sc.nextInt(); //2, 3
int d = sc.nextInt(); //0, 1
int x = sc.nextInt(); //1, 2
int y = sc.nextInt(); //1, 3
// ๊ฐ๋ก๋ฐฉํฅ
if(d == 0){
for(int i=1; i<=l; i++){
arr[x][y+i-1] = 1; //1 1,1 2 (์์๋ฅผ ํ ๋๋ก ์ขํ๋ฅผ ํ์ธ)
}
}
//์ธ๋ก๋ฐฉํฅ
else if(d == 1){
for(int i=1; i<=l; i++){
arr[x+i-1][y] = 1; //2 3, 3 3, 4 3 //2 5, 3 5, 4 5, 5 5 (์์๋ฅผ ํ ๋๋ก ์ขํ๋ฅผ ํ์ธ)
}
}
}
sc.close();
//์ถ๋ ฅ
for(int i=1; i<=h; i++){
for(int j=1; j<=w; j++){
System.out.printf("%d ", arr[i][j]);
}
System.out.println();
}
}
}