Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var lista = document.getElementsByTagName("td");
- var contor = [];
- var ture = 100;
- var aparitiaNumerelorDeCeleMaiMulteOri = 12;
- // Play
- init();
- split();
- minim();
- maxim();
- // Init null array
- function init(){
- for(var j=1;j<=49;j++){
- contor[j] = 0;
- }
- }
- // Split string into array
- function split(){
- for(var i=11; i<11+(ture*4); i+=4){
- var rezultat = lista[i].innerHTML.split(", ");
- rezultat.forEach(numara);
- }
- function numara(item){
- contor[item]++;
- }
- }
- // Maximul
- function maxim(){
- max = contor[1];
- k = 0;
- for(var y=1; y<contor.length;y++){
- if(contor[y]>max){
- max = contor[y];
- }
- }
- do{
- for(var y=1; y<contor.length;y++){
- if(contor[y]==max && k<aparitiaNumerelorDeCeleMaiMulteOri){
- console.log("MAXIM:Numarul " + y + " apare de " + max + " ori");
- k++;
- }
- }
- max--;
- }while(k!=aparitiaNumerelorDeCeleMaiMulteOri);
- }
- function minim(){
- min = contor[1];
- k = 0;
- for(var y=1; y<contor.length;y++){
- if(contor[y]<min){
- min = contor[y];
- }
- }
- do{
- for(var y=1; y<contor.length;y++){
- if(contor[y]==min && k<aparitiaNumerelorDeCeleMaiMulteOri){
- console.log("MINIM: Numarul " + y + " apare de " + min + " ori");
- k++;
- }
- }
- min++;
- }while(k!=aparitiaNumerelorDeCeleMaiMulteOri);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement