#45848: python超明暸解法


11310495 (李仲鎧台中一中)

學校 : 國立臺中第一高級中學
編號 : 307204
來源 : [114.33.7.185]
最後登入時間 :
2025-05-03 16:17:04
a147. Print it all | From: [114.33.7.185] | 發表日期 : 2025-04-19 13:25

while True:                            #製造無限迴圈
    ans=""                              #要輸出的答案(一開始為空字串)
    n=int(input())                   #輸入n
    if n<=10000 and n>0:     #符合題目要件才開始檢查
        for i in range(1,n):        #從1檢驗到n-1(不含n)    
            if i%7!=0:                 #如果不是7的倍數則將被丟入ans字串中
                ans+=(str(i)+" ")
    elif n==0:                          #如果輸入0則跳出迴圈
        break
    print(ans)                          #輸出解答

#希望以上能夠幫助到你

 
ZeroJudge Forum