Advertisement
arturParchem

[P] Lider

Oct 10th, 2022
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. A=[7,7,10,7,7,10,7,10,7,10,10]
  2. def element(A):
  3.     akt=A[0]
  4.     ile_razy=1
  5.     for i in range(len(A)):
  6.         if A[i]==akt:
  7.             ile_razy+=1
  8.         elif ile_razy>0:
  9.             ile_razy-=1
  10.         else:
  11.             akt=A[i]
  12.             ile_razy=1
  13.     zlicz=0
  14.     for i in range(len(A)):
  15.         if A[i]==akt:
  16.             zlicz+=1
  17.     if zlicz>len(A)//2:
  18.             print(akt)
  19.     else:
  20.         print("nie ma tekiego elemntu")
  21. element(A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement