Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions Seol-JY/202502/04 BOJ S2 별찍기 - 22
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
```java
import java.io.*;

public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());

if (N == 1) {
System.out.println("*");
return;
}

char[][] map = new char[3 + 4 * (N-1)][1 + 4 * (N-1)];
for (int i = 0; i < 3+4*(N-1); i++) {
for (int j = 0; j < 1+4*(N-1); j++) {
map[i][j] = ' ';
}
}

int r = N * 2;
int c = N * 2 - 2;
int directionR = 1;
int directionC = -1;
int weight = 1;
for (int i = 0; i < 1+4*(N-1); i++) {
if (i % 2 == 0) {
directionR *= -1;
weight += 2;
for (int j = 0; j < weight; j++) {
r = j!=0 ? r + directionR : r;
map[r][c] = '*';
}
} else {
directionC *= -1;
for (int j = 0; j < weight; j++) {
c = j!=0 ? c + directionC : c;
map[r][c] = '*';
}
}
}

BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
for (int i = 0; i < 3+4*(N-1); i++) {
for (int j = 0; j < 1+4*(N-1); j++) {
if (i == 0) {
bw.write("*");
continue;
}
if (i == 1 && j >= 1) continue;
if (j == 4*N - 4) {
bw.write(map[i][j]);
} else {
bw.write(map[i][j]);
}
Comment on lines +51 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 이거 둘 다 똑같은 거 아닌가요 ❓

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oncsr 어 그렇네요...? 감사합니다...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

신의 일침 ㄷㄷ

}
bw.write("\n");
}
bw.flush();
bw.close();
}
}
```