题解 | #菱形图案#
菱形图案
http://www.nowcoder.com/practice/8b935f8ffe99445dbd42494febd13e45
BC105 菱形图案
思路:
step1:分上下层打印;
代码如下:
while True:
try:
n = int(input())
i = 1
while i <= 2*n + 1:
j = n + 1
while j >= 1:
if i <= j:
if i >= j:
print('* ',end='')
else:
print(' ',end='')
elif i > j:
if i + j <= 2*n + 2:
print('* ',end='')
else:
print(' ',end='')
j -= 1
print()
i += 1
except:
break