INPUT = Line ( " Please enter a positive integer must be odd: " ) Line = int (Line) IF Line% 2 == 0: maxspaceNum = Line 2 // I =. 1 linespaceNum = maxspaceNum the while linespaceNum> = 0: Print ( " " linespaceNum, End = "" ) Print ( " * " * (I-2 *. 1 )) linespaceNum -. 1 = I +. 1 = I - = 2 linespaceNum + 2 = while linespaceNum <= maxspaceNum: print(" " * linespaceNum ,end="") print("*" * (2*i-1)) linespaceNum += 1 i -= 1
Use a while loop to print a diamond, diamond to an asterisk (*) printing. The number of rows required from the diamond python console input, line number must be odd.
Guess you like
Origin www.cnblogs.com/ppystudy/p/12109754.html
Recommended
Ranking