OK, I have an array with numbers, and an array with the number of occurences of each corresponding number from the number array. I need to display the numbers from number array which occured the most. The way I did it, it displays them and they repeat themselves. E.g. 7 occured 7 times, 87 occured 7 times, 7 occured 7 times etc. It is supposed to display it only once. Can somebody give me hint how to do that?
What I have so far is this:
Code:
for(i = 0; i < SIZE; i++)
{
search = numbers[i];
for(j = 0; j < SIZE; j++)
{
if(numbers[j] == search)
occurences[i]++;
}
}
printf("\n");
largest_occ = occurences[0];
for(i = 0; i < SIZE; i++)
{
if(largest_occ < occurences[i])
largest_occ = occurences[i];
}
for(i = 0; i < SIZE; i++)
{
if(largest_occ == occurences[i])
{
modes[j] = largest_occ;
j++;
}
}
The last for loop was to put all the modes in a separate array so I could filter it, but it does not work.
Any hints how I could go about it?