I am trying to make a function that will find the mode of an array, I have it find the mode but I am still trying to make it that if there are more than 1 modes in the array it will return unavailable.
int amount=0;
int counter=0;
int mode = 0;
for(int i =0; i<size; i++){
counter=0;
for(int j=0; j<size; j++){
if(a[i] == a[j])
++counter;
}
if(counter > amount){
mode = a[i];
amount = counter;
}
}
Aucun commentaire:
Enregistrer un commentaire