inblog logo
|
DailyCoding
    Practice

    4. 별(5→1)

    박은서's avatar
    박은서
    Dec 08, 2025
    4. 별(5→1)
    Contents
    풀이정답

    풀이

    package ex03; public class Test4Me { public static void main(String[] args) { int k = 6; for (int j = 0; j < 5; j++) { k--; for (int i = 0; i < k; i++) { System.out.print("*"); } System.out.println(); } } }
    notion image

    정답

    for문 몇 회전 할건지도 변수로 선언
    package ex03; public class Test4T { public static void main(String[] args) { // ***** // **** // *** // ** // * String star = "*"; int c = 5; int row = 5; for (int k = 0; k < row; k++) { for (int i = 0; i < c; i++) { System.out.print(star); } System.out.println(); c--; } } }
    notion image
    Share article
    Contents
    풀이정답

    DailyCoding

    RSS·Powered by Inblog