Comment detail

ピラミッドを作る (Nested Flatten)

Felioさんの回答を参考にしました。

1
2
3
4
5
6
7
8
def print_pyramid( n ){
    (1..n).each{
        def text = "*"*(2*it - 1)
        println text.center(2*n + 1)
    }
}

print_pyramid(10)

Index

Feed

Other

Link

Pathtraq

loading...