Advertisement
arturParchem

[P] Lider losowy

Oct 10th, 2022
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. from random import randint
  2. A=[7,7,10,4,10,10,5,10,7,10]
  3. K=20
  4. def losowy_lider(A):
  5.     for i in range(K):
  6.         x=A[randint(0,len(A)-1)]
  7.         zlicz=0
  8.         for i in range(len(A)):
  9.             if A[i]==x:
  10.                 zlicz+=1
  11.         if zlicz>len(A)//2:
  12.             return x
  13.     return "Nie ma lidera"
  14. print(losowy_lider(A))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement