File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.* ;
3+ import java.util.* ;
4+
5+ public class Main {
6+
7+ static char [][] map;
8+
9+ public static void main (String [] args ) throws Exception {
10+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
11+ int n = Integer . parseInt(br. readLine());
12+
13+ map = new char [n][2 * n - 1 ];
14+
15+ for (int i = 0 ; i < n; i++ ) {
16+ Arrays . fill(map[i], ' ' );
17+ }
18+
19+ draw(0 , n - 1 , n);
20+
21+ StringBuilder sb = new StringBuilder ();
22+ for (int i = 0 ; i < n; i++ ) {
23+ sb. append(map[i]). append(' \n ' );
24+ }
25+
26+ System . out. print(sb);
27+ }
28+
29+ static void draw (int r , int c , int n ) {
30+ if (n == 3 ) {
31+ map[r][c] = ' *' ;
32+ map[r + 1 ][c - 1 ] = ' *' ;
33+ map[r + 1 ][c + 1 ] = ' *' ;
34+ for (int i = - 2 ; i <= 2 ; i++ ) {
35+ map[r + 2 ][c + i] = ' *' ;
36+ }
37+ return ;
38+ }
39+
40+ int half = n / 2 ;
41+
42+ draw(r, c, half);
43+ draw(r + half, c - half, half);
44+ draw(r + half, c + half, half);
45+ }
46+ }
47+
48+ ```
You can’t perform that action at this time.
0 commit comments