-
2438번: 별 찍기 - 1코테/백준 2024. 5. 23. 20:19
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 j = 1; j <= i; j++) { System.out.print("*"); } System.out.println(); } sc.close(); } }
for 문을 이용해 Scanner 로 받은 개수 만큼의 별이 찍히게 할 수 있다.
'코테 > 백준' 카테고리의 다른 글
10951번: A + B (4) (0) 2024.05.29 2439: 별 찍기 -2 (0) 2024.05.24 11022번: A + B (8) (0) 2024.05.22 11021번: A + B (7) (0) 2024.05.20 25314번: 코딩은 체육과목 입니다 (0) 2024.05.17