본문 바로가기

알고리즘/Java

(JAVA) 백준 알고리즘 5단계 2523번 : 별 찍기 - 13

실습4

기본적인 별찍기

 

소스

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
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=1; i<=a; i++){
                for(int j=1; j<=i; j++){
                    System.out.print("*");
                }
                System.out.println();
            }
            for(int n=a-1; n>=1; n--){
                for(int m=n; m>=1; m--){
                    System.out.print("*");
                }
                System.out.println();
            }
        }
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
s