Comment detail

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

Felioさんのを参考に。

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

print_pyramid(10)

Index

Feed

Other

Link

Pathtraq

loading...