PHP
·
发表于 5年以前
·
阅读量:8286
n = 4
for i in range(2*n-1):
if i < n:
number = 2 * i +1
else:
number = 2*(2*n-1-i)-1
print(('*' * number).center(2*n-1, " "))
n = 4
_max = 2 * n - 1
a = [("*"*e).center(_max," ")for e in [2*i - 1 if i<=n else 4*n-2*i-1 for i in range(1, _max+1)]]
for each in a:
print(each)