File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed
Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+
3+ import java.util.* ;
4+ import java.io.* ;
5+
6+ class Main {
7+
8+ // IO field
9+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
10+ static BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System . out));
11+ static StringTokenizer st;
12+
13+ static void nextLine () throws Exception {st = new StringTokenizer (br .readLine ());}
14+ static int nextInt() {return Integer . parseInt(st. nextToken());}
15+ static long nextLong() {return Long . parseLong(st. nextToken());}
16+ static void bwEnd() throws Exception {bw. flush();bw. close();}
17+
18+ // Additional field
19+
20+ public static void main(String [] args) throws Exception {
21+
22+ int N = Integer . parseInt(br. readLine());
23+
24+ if (N == 1 ) {
25+ bw. write(" *" );
26+ bwEnd();
27+ return ;
28+ }
29+
30+ char [][] ans = new char [4 * N - 1 ][4 * N - 3 ];
31+ for (int i= 0 ;i< 4 * N - 1 ;i++ ) Arrays . fill(ans[i], ' ' );
32+
33+ int a = 0 , b = 4 * N - 4 , c = 4 * N - 2 ;
34+ while (a<= b) {
35+ for (int i= a;i<= b;i++ ) {
36+ ans[a][i] = ' *' ;
37+ ans[c][i] = ' *' ;
38+ }
39+ for (int i= a;i<= c;i++ ) {
40+ ans[i][a] = ' *' ;
41+ ans[i][b] = ' *' ;
42+ }
43+ if (a != 0 ) ans[a][b+ 1 ] = ' *' ;
44+ if (a != b) ans[a+ 1 ][b] = ' ' ;
45+ a += 2 ;
46+ b -= 2 ;
47+ c -= 2 ;
48+ }
49+
50+ for (int i= 0 ;i< 4 * N - 1 ;i++ ) {
51+ for (int j= 0 ;j< 4 * N - 3 ;j++ ) {
52+ bw. write(ans[i][j]);
53+ if (i == 1 && j == 0 ) break ;
54+ }
55+ bw. write(" \n " );
56+ }
57+
58+ bwEnd();
59+ }
60+
61+ }
62+
63+ ```
You can’t perform that action at this time.
0 commit comments