算法——三角形图形

三角形图形

# triangle.py
def triangle(n: int) -> None:
    row = n
    for i in range(row-1):
        # asterisk & new line
        print('*' * (i+1), end='')
        # whitespace
        print(' ' * (n-i-1), end='')
        # whitespace
        print(' ' * (row-i-1), end='')
        # asterisk & new line
        print('*' * (i+1))
    for i in range(row):
        # asterisk 
        print('*' * (row - i), end='')
        # whitespace
        print(' ' * (i), end='')
        # whitespace
        print(' ' * (i), end='')
        # asterisk & new line
        print('*' * (row - i))



if __name__ == '__main__':
    triangle(20)

算法——三角形图形

上一篇:【BZOJ】2179: FFT快速傅立叶(fft)


下一篇:STM32实现将简单的参数保存至flash,掉电不重置