前几天有个面试,面试官叫我写一个直角三角形,因为有点紧张,所以没有写出来,今天有空正好把这些都写出来.
# *
# * *
# * * *
# * * * *
def zhijiaosanjiao1(n):
for i in range(1,n+1):
for j in range(1,i+1):
print("*",end=' ')
print()
zhijiaosanjiao1(4)
# *
# * *
# * * *
# * * * *
# * * * * *
# * * * * * *
# * * * * * * *
# def zhijiaosanjiao2(n):
# for i in range(1,n+1):#横轴
# for j in range(1,n):#竖轴
# if i+j<=n:
# print(' ',end=' ')
# else:
# print('*',end=' ')
# print()
# zhijiaosanjiao2(8)
# * * * *
# * * *
# * *
# *
# def zhijiaosanjiao3(n):
# for i in range(1,n+1):
# for j in range(1,n+1):
#