• 使用循环输出下面图形
1
2
3
4
5
6
7
8
9
    *
***
*****
*******
*********
*******
*****
***
*
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
for i in range(1,10,2):    #正序输出
b = '*' * i
b=b.center(9)
print(b)
#for j in range(7,0,-2):
# c = '*' * j
# c = c.center(9)
# print(c)
for j in reversed(range(1,8,2)): #反序输出
c = '*' * j
c = c.center(9)
print(c)
#for j in range(1,8,2)[::-1]:
# c = '*' * j
# c = c.center(9)
# print(c)

  • 三种反序手法,可以任选一种
1
2
3
4
5
6
7
8
9
    *    
***
*****
*******
*********
*******
*****
***
*