알고리즘
[백준, 자바, 2522번] 별찍기 - 12
hminor
2024. 2. 13. 10:57
반응형
풀이
- 없음
import java.io.*;
public class 별찍기12 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
for (int i = 1; i < 2*n; i++) {
if (i <= n) {
for (int j = 0; j < n-i; j++) System.out.print(" ");
for (int j = 0; j < i; j++) System.out.print("*");
} else {
for (int j = 0; j < i-n; j++) System.out.print(" ");
for (int j = 0; j < 2*n-i; j++) System.out.print("*");
}
System.out.println();
}
}
}