Advertisement
arturParchem

[P] Dominant

Oct 3rd, 2022
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. t=[1,2,2,2,2,2,5,2,5,2,2,9,1]
  2. t.sort()
  3. def dominanta(A):
  4.     dominant = A[0]
  5.     ile_dom = 0
  6.     for i in A:
  7.         aktualny=i
  8.         ile=0
  9.         for x in A:
  10.             if x==i:
  11.                 ile+=1
  12.         if ile>ile_dom:
  13.             ile_dom=ile
  14.             dominant=aktualny
  15.     if ile_dom>len(A)//2:
  16.         return "Dominantem jest "+str(dominant)
  17.     else:
  18.         return("Dominanta nie ma :(")
  19. print(dominanta(t))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement