# *
# * *
# * * *
# * * * *
# * * * * *

x = 0
while x < 5:
    x += 1
    # 每次循环需要给y赋值0.清空y中存储的值
    y = 0
    while y < x:
        print('*', end='')
        y += 1
    print('')
# *
# * *
# * * *
# * * * *
# * * * * *
# * * * *
# * * *
# * *
# *
row = 0
while row < 5:
    row += 1
    col = 0
    while col < row:
        col += 1
        print('*', end='')
    print('')
while 5<= row < 9:
    row += 1
    col = 9
    while col >= row:
        col -= 1
        print('*', end='')
    print('')

相关文章:

  • 2021-07-23
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2021-09-29
  • 2021-07-15
猜你喜欢
  • 2021-11-24
  • 2022-12-23
  • 2021-11-10
  • 2021-12-03
  • 2021-05-10
  • 2022-12-23
  • 2021-04-20
相关资源
相似解决方案