TIL #78

loci·2024년 7월 18일
0

TIL

목록 보기
76/103


백준 10992번
그림과 같이 출력해야한다.

fun main() {
    val n = readLine()!!.toInt()
    for (i in 1..n) {
        for (j in 1..n - i) {
            print(" ")
        }
        if (i == 1 ||i == n) {
            for (j in 1..i * 2 -1) {
                print("*")
            }
        } else {
            print("*")
            for(i in 1..2*i-3){
                print(" ")
            }
            print("*")
        }
        println()
    }

}
profile
편리한 개발자

0개의 댓글