๐Ÿ•ธ Algorithm/๐Ÿ•ธ ๋ฐฑ์ค€ BaekJoon

[๋ฐฑ์ค€][java][2439][๋ณ„ ์ฐ๊ธฐ - 2]

๋‰ด์ด NUEY 2023. 10. 9. 21:58
๋ฐ˜์‘ํ˜•

import java.util.Scanner;

public class Main {
	// 2439	๋ณ„ ์ฐ๊ธฐ - 2
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int t = sc.nextInt();
		String star = "";
		
		for (int i=1; i<=t; i++) {
			String space = "";
			star += "*";

			for (int j=0; j<t-i; j++) {
				space += " ";
			}
			
			System.out.print(space);
			System.out.println(star);
		} 
	}
}

๋ณ€์ˆ˜ ์„ ์–ธ์˜ ์œ„์น˜์™€ +=๋Œ€์ž…์—ฐ์‚ฐ์ž์˜ ์œ„์น˜๋งŒ ์ž˜ ์ ์–ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๋ฐ˜์‘ํ˜•