106 lines
610 B
Java
106 lines
610 B
Java
public class Exotrois {
|
|
|
|
|
|
public static <T> plusFrequent(T[] tableau){
|
|
|
|
|
|
T valeurGagnante = tableau[0];
|
|
int frequenceGagnante = 0;
|
|
int premierIndexGagnant = tableau.length;
|
|
|
|
|
|
|
|
for(int i=0;i<tableau.length; i++){
|
|
|
|
|
|
|
|
T valeurCourante = tableau[i];
|
|
|
|
|
|
|
|
|
|
|
|
int frequenceCourante =0;
|
|
for(int k=0; k<tableau.length; k++){
|
|
|
|
if(Object.equals(tableau[k], valeurCourante)){
|
|
|
|
frequenceCourante++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
int premierIndexCourant = -1;
|
|
for(int j=0; j<tableau.length; j++){
|
|
|
|
if(Object.equals(tableau[j]), valeurCourante){
|
|
|
|
premierIndexCourant=j;
|
|
break;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |