運算思維與程式設計課程程式範例: Python

This Post Has 2 Comments

  1. 三角形列印練習(1)

    n = int(input("請輸入N(高,4~9):"))
        
    for i in range(n):
        for j in range(i+1):
            print("*", end='')
        print('')
    
  2. 三角形列印練習(2)

    n = int(input("請輸入N(高,4~9):"))
        
    for i in range(n):
        for j in range(n):
            if (j<n-i-1):
                print(" ", end='')
            else:
                print("*", end='')
        print('')
    

發佈留言

Close Menu
error: