SHARE
TWEET

Untitled

a guest Oct 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #input
  2. a = [7,4,5,3,9,7,2]
  3. #main
  4. b = []
  5. for i in range (0,len(a)):  #複製陣列,不能直接用=    (=為參考)
  6.   b.append(a[i])
  7. b.sort()        #排序
  8. K = 1           #判斷為第幾的數字
  9. Q = 0           #此數字所在的index
  10. for i in range (1,len (b)):     #判斷
  11.   if b[i] != b [i-1]:
  12.     K += 1
  13.   if K == 5:
  14.     print(b[i])
  15.     Q = i
  16.     break
  17.  
  18. c = []          #儲存a存有此數字的index
  19. for i in range (0,len(a)):
  20.   if a[i] == b[Q]:
  21.     c.append(i)
  22. print (c)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top