-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2447.java
More file actions
48 lines (38 loc) · 1.01 KB
/
2447.java
File metadata and controls
48 lines (38 loc) · 1.01 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
import java.util.*;
public class Main {
static char[][] arr;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
arr = new char[N][N];
StringBuilder sb = new StringBuilder();
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
arr[i][j] = ' ';
}
}
star(0, 0, N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
sb.append(arr[i][j]);
}
sb.append("\n");
}
System.out.println(sb);
}
public static void star(int x, int y, int n) {
if (n == 1) {
arr[x][y] = '*';
return;
}
n /= 3;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i == 1 && j == 1) {
continue;
}
star(x + (i * n), y + (j * n), n);
}
}
}
}