도저히 모르겠어서 다른 분 코드를 보고 이해했다. 넘 어려웠따,,,
소스
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
|
public class Main{
public static void main(String[]args){
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if(a>=1 && a<=100){
//역삼각형
for (int i=0; i<a; i++) {
for (int j=0; j<i; j++) {
System.out.print(" ");
}
for (int k=0; k<(2*a-1)-(2*i); k++) {
System.out.print("*");
}
System.out.println();
}
// 삼각형
for (int i=0; i<a-1; i++) {
for (int j=1; j<(a-1)-i; j++) {
System.out.print(" ");
}
for (int k=0; k<3+2*i; k++) {
System.out.print("*");
}
System.out.println();
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
'알고리즘 > Java' 카테고리의 다른 글
(JAVA) 백준 알고리즘 6단계 10818번 : 최소, 최대 (0) | 2020.04.23 |
---|---|
(JAVA) 백준 알고리즘 5단계 10996번 : 별 찍기 - 21 (0) | 2020.04.22 |
(JAVA) 백준 알고리즘 5단계 2523번 : 별 찍기 - 13 (0) | 2020.04.20 |
(JAVA) 백준 알고리즘 5단계 10817번 : 세 수 (0) | 2020.04.19 |
(JAVA) 백준 알고리즘 5단계 5543번 : 상근날드 (0) | 2020.04.19 |