8
I need to find frequency of ages in a vector. I know how to do this when the vector is small, but not when it is large. Consider the vector below:
int[] idade = {15,18,15,20,16,30,18,45,43,14,25,16,20};
For this vector, I could do a sequential search to find how many people are the same age:
for(i = 0; i < idade.length; i++){
if(idade[i] == 14) i14++;
if(idade[i] == 15) i15++;
if(idade[i] == 16) i16++;
/*if(...*/
}
Only I’m not finding a way to find the occurrence of equal ages when the vector has more than 1,000 positions. Can someone give me a hint as to how this can be done?
Thank you very much!
Hi, @Severmateus! Thank you so much for answering! I’ve already solved it! Thank you so much! _ Your solution helped me in another question!
– Van Ribeiro