I would like to find out which label occurs most frequently. I first count the number of occurrences of each label. Then compare the occurrences and find out the maximum. But now I need to add an addition requirement: If 2 labels have the same occurances, return label "unknown".
Could anybody help me with the part of "identify which is the most frequent label"? There seems some error in the arrangement of the if statement and for loop, because the output is always different to what is expected.
index 7 is sticky. Once you've found it once, there's no point carrying on with the search.
1 2 3 4 5 6 7 8 9 10
for (int i = 0; index < 7 && i < 8; i++){
for (int j = i; index < 7 && j < 8; j++){
if(number[i] == number[j]){
index = 7;
}elseif (number[i] > max){
max = number[i];
index = i;
}
}
}