line = input("请输入一个正整数,必须是奇数:") line=int(line) if line % 2 ==0: maxspaceNum = line // 2 i = 1 linespaceNum = maxspaceNum while linespaceNum >= 0: print(" " linespaceNum,end="") print("*" * (2*i-1)) linespaceNum -= 1 i += 1 i -=2 linespaceNum += 2 while linespaceNum <= maxspaceNum: print(" " * linespaceNum ,end="") print("*" * (2*i-1)) linespaceNum += 1 i -= 1
原文地址:https://www.cnblogs.com/ppystudy/p/12109754.html
时间: 2024-11-08 05:02:02