Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. modul = function (esantion)
  2. {
  3. esantion=sort(esantion)
  4. lg = 1
  5. i = 2
  6. lgmax = 1
  7. vectoras = vector()
  8. nmax = length(esantion)
  9. while(i < nmax) #cauti lungimea maxima , gen 2 2 2 4 4 5 = 3 deoarece ai 3 de 2
  10. {
  11. if(esantion[i] == esantion[i-lg])
  12. {
  13. lg = lg + 1
  14. }
  15. i = i + 1
  16. }
  17. i = 1
  18. lgm=1
  19. while(i < nmax-1) #verifici la fiecare pas daca lungimea curenta este egala cu cea maxima si afisezi
  20. {
  21. if(esantion[i] == esantion[i+1])
  22. {
  23. lgm = lgm + 1
  24. }
  25. else
  26. if(lgm == lg)
  27. {
  28. lgm=1
  29. vectoras=c(vectoras,esantion[i])
  30. }
  31. i = i + 1
  32. }
  33. return (vectoras)
  34. }
  35.  
  36. sample=c(3, 6, 4, 3, 6, 7, 8, 5, 3, 6)
  37. sort(sample)
  38. modul(sample)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement