영보의 SystemOut.log

[JAVA]백준2439번 - 별찍기2 본문

Language/JAVA

[JAVA]백준2439번 - 별찍기2

영보로그 2020. 7. 1. 19:04
반응형

* 문제

 

 

* 코드

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
import java.util.Scanner;
public class Main {
 
    public static void main(String[] args) {
        
        int num = 0;
        
        Scanner scan=new Scanner(System.in);
        num=scan.nextInt();
        
        if(num>=1 && num<=100)
        {
            for(int i=1;i<=num;i++)
            {
                for(int p=1;p<=num-i;p++)
                {
                    System.out.print(" ");
                }
                for(int j=1;j<=i;j++)
                {
                    System.out.print("*");
                }
                System.out.println();
                }
            }
        }
    }
cs

 

 

 

반응형