本帖最后由 闫露 于 2018-7-30 23:28 编辑
使用while循环输出如下图形:(必须使用双重while循环实现)row = 1 while row <= 5: col = 1 while col <= row: if col == 1: print(" "*(5 - row), end="") print("* ", end="") col += 1 print("") row += 1 使用while,完成以下图形的输出。(每一行的星星不能用*乘以星星的数量来完成,须使用while嵌套)(较难)
row = 1 while row <= 5: col = 1 while col <= 2 * row - 1: if col == 1: print(" " * (5 - row), end="") print("*", end="") col += 1 print("") row += 1 row = 6 while 5 < row <= 9: col = 1 while col <= 9 - (row - 5) * 2: if col == 1:
print(" " * (row - 5), end="")
print("*", end="")
col += 1
print("")
row += 1
|