打印菱形
程序员文章站
2024-03-23 18:37:34
...
'''打印出如下图案(菱形):
*
***
*****
*******
*****
***
*'''
k = int(input('请输入菱形的边长:'))
c = 2*k-1
b = 1
while True:
a = int((c - b) / 2)
print(' ' * a + '*' * b + ' ' * a)
b+=2
if b==c+2:
b = c
while True:
b-=2
a = int((c - b) / 2)
print(' ' * a + '*' * b + ' ' * a)
if b == 1:
break
break