<문제>
첫째 줄부터 2×N-1번째 줄까지 차례대로 별을 출력한다.
<예제>
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
|
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
for(int i=1; i<=num; i++) {
for(int j=0; j<i; j++) {
System.out.print("*");
}
System.out.println();
}
for(int i=1; i<num; i++) {
for(int j=num-i; j>0; j--) {
System.out.print("*");
}
System.out.println();
}
}
}
|
'알고리즘 > 백준' 카테고리의 다른 글
[백준 10818번 ː 자바(JAVA)] 최소, 최대 (0) | 2020.04.22 |
---|---|
[백준 2446번 ː 자바(JAVA)] 별 찍기 - 9 (0) | 2020.04.21 |
[백준 10817번 ː 자바(JAVA)] 세 수 (0) | 2020.04.21 |
[백준 5543번 ː 자바(JAVA)] 상근날드 (0) | 2020.04.20 |
[백준 10039번 ː 자바(JAVA)] 평균 점수 (0) | 2020.04.20 |