본문 바로가기
with my rubber duck/codingTest

백준 2441 별 찍기 - 4 자바

by stilinski 2022. 4. 17.
728x90

문제

 

내 코드

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        for(int i = 0;i<n;i++){
            for(int j = 0;j<i;j++){
                System.out.print(" ");
            }
            
            for(int k = n-i;k>0;k--){
                System.out.print("*");
            }
            System.out.println();
        }
        
    }

}

뭔가 다른 방법이 있었던 거 같은데 기억이 안나부러

 

728x90

댓글