Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Python by curry ( 4 years ago )
# homework_3.py

num = input('請輸入小於 10000 的整數: ')

def printList(def_num):
    num_array = num.split()
    # 輸入第一個值,並放入陣列

    def_num = int(def_num)
    while def_num > 1:
        def_num -= 1
        if def_num % 7 == 0:
            def_num -= 1
        num_array.append(def_num)
    # 循環輸出所有小於 def_num ,大於 0 且不為 7 的倍數的數並放入 num_array

    num_array.reverse()
    # 反轉 num_array

    len_array = len(num_array)
    # 取得列表長度

    n = 0
    for len_array in num_array:
        print(num_array[n], end=' ')
        n += 1
    # 輸出列表內容
# 定義函式

num = int(num)
if num == 0:
    print('')

elif num % 7 != 0:
    num = str(num)
    printList(num)
    # 呼叫函式

else:
    #num % 7 == 0
    num -= 1
    num = str(num)
    printList(num)

 

Revise this Paste

Children: 114670
Your Name: Code Language: