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

백준 2442 자바

by stilinski 2022. 4. 18.
728x90

문제

답 코드

import java.util.Scanner;

public class Main {

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

}

 

 

728x90

댓글