1.
cengshu=int(input("层数:"))
for i in range(0,cengshu):
for j in range(0,2*i+1):
print("*",end='')
print()#print有自动换行的功能
2.
cengshu=int(input("层数:"))
for i in range(0,cengshu):
for k in range(0, cengshu - i):
print("1", end='')
for j in range(0,2*i+1):
print("*",end='')
for kk in range(0, cengshu - i):
print("1", end='')
print()#print有自动换行的功能
3.
cengshu=int(input("层数:"))
for i in range(0,cengshu):
for k in range(0, cengshu - i):
print(" ", end='')
for j in range(0,2*i+1):
print("*",end='')
for kk in range(0, cengshu - i):
print(" ", end='')
print()#print有自动换行的功能
4.
cengshu=int(input("层数:"))+1
for i in range(1,cengshu):
for j in range(0,i):
print("*",end='')
print()#print有自动换行的功能
5.
cengshu=int(input("层数:"))+1
for i in range(1,cengshu):
for k in range(0,cengshu-i):
print('1',end='')
for j in range(0,i):
print("*",end='')
for k in range(0,cengshu-i):
print('1',end='')
print() # print有自动换行的功能
6.
cengshu=int(input("层数:"))+1
for i in range(1,cengshu):
for k in range(0,cengshu-i-1):
print(' ',end='')
for j in range(0,i):
print("*",end='')
print() # print有自动换行的功能
7.
cengshu=int(input("层数:"))+1
for i in range(1,cengshu):
for j in range(0,i):
print("*",end='')
print(' ', end='')
print() # print有自动换行的功能
8.空心三角形
num=int(input("层数:"))
for i in range(num):
tab = False
for j in range(i+1):
if i!=num-1:
if j==i:
tab=True
if(i==j or j==0):
print("*",end='')
else:
print(" ",end='')
else:
print("*",end='')
if tab:
print()