Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modul = function (esantion)
- {
- esantion=sort(esantion)
- lg = 1
- i = 2
- lgmax = 1
- vectoras = vector()
- nmax = length(esantion)
- while(i < nmax) #cauti lungimea maxima , gen 2 2 2 4 4 5 = 3 deoarece ai 3 de 2
- {
- if(esantion[i] == esantion[i-lg])
- {
- lg = lg + 1
- }
- i = i + 1
- }
- i = 1
- lgm=1
- while(i < nmax-1) #verifici la fiecare pas daca lungimea curenta este egala cu cea maxima si afisezi
- {
- if(esantion[i] == esantion[i+1])
- {
- lgm = lgm + 1
- }
- else
- if(lgm == lg)
- {
- lgm=1
- vectoras=c(vectoras,esantion[i])
- }
- i = i + 1
- }
- return (vectoras)
- }
- sample=c(3, 6, 4, 3, 6, 7, 8, 5, 3, 6)
- sort(sample)
- modul(sample)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement