打印空心三角形 ''' * 1 * * 2 * * 3 ******* 4 ''' a = int(input("输入行数:")) for i in range(0,a+1): #空格数 space = a - i for j in range(space): print(" ",end="") #星数 star = 2 * i - 1 for k in range(star): #z中心判断是
打印空心三角形
'''* 1
* * 2
* * 3
******* 4
'''
a = int(input("输入行数:"))
for i in range(0,a+1):
#空格数
space = a - i
for j in range(space):
print(" ",end="")
#星数
star = 2 * i - 1
for k in range(star):
#z中心判断是否输出为*
if k == 0 or k == star - 1 or i == a:
print("*",end="")
else:
print(" ",end="")
#换行
print()