在控制台连续输出五行*,每一行星号的数量依次递增
row=1 while row<=5: col=1 while col<=row: print(‘*‘,end=‘‘) col+=1 print() row+=1 # 输出结果 # * # ** # *** # **** # *****
02:
row=5 while row>=1: col=1 while col<=row: print(‘*‘,end=‘‘) col+=1 print(‘‘) row-=1 # 输出结果 # ***** # **** # *** # ** # *
03:
row=1 while row<=5: col=1 space=1 while col <=5-row: print(‘ ‘,end=‘‘) col+=1 while space<=row: print(‘*‘,end=‘‘) space+=1 print(‘‘) row+=1 # 输出结果: # # * # ** # *** # **** # ***
04:
row=5 while row>=1: col=1 space=1 while col<=5-row: print(‘‘,end=‘‘) col+=1 while space<=row: print(‘*‘,end=‘‘) space+=1 print(‘‘) row -= 1 # 输出结果: # ***** # **** # *** # ** # *
原文地址:https://www.cnblogs.com/kelly11/p/12125512.html
时间: 2024-10-07 00:11:24