반응형
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
28
29
30
31
32
33
34
|
import java.util.Scanner;
class MainClass{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
for(int i = 0; i < num; ++i){
for(int j = 0; j < i+1; ++j){
System.out.print("*");
}
for(int k = 0; k < (num-i-1)*2; ++k) {
System.out.print(" ");
}
for(int j = 0; j < i+1; ++j){
System.out.print("*");
}
//8 6 4 2 0
System.out.println();
}
for(int i = 0; i < num-1; ++i){
for(int j = 0; j <num-1-i ; ++j){
System.out.print("*");
}
for(int k = 0; k < i*2+2; ++k){
System.out.print(" ");
}
for(int j = 0; j <num-1-i ; ++j){
System.out.print("*");
}
System.out.println();
}
}
}
|
cs |
반응형
'알고리즘 > 코드 연습' 카테고리의 다른 글
[LeetCode] Add Two Numbers (0) | 2021.12.30 |
---|---|
[백준 - 1316] 그룹 단어 체커 (0) | 2020.11.27 |
[백준-1764] 듣보잡 (0) | 2020.07.31 |
[백준 - 1924] 2007년 (0) | 2020.07.29 |
[백준 - 2798] 블랙잭 (0) | 2020.07.24 |