题解 | #K形图案#
K形图案
http://www.nowcoder.com/practice/753cc2662d9949fe826a85f815db0ca4
BC106 K形图案
思路:
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