I need to find age frequency in a vector. I know how to do this when the vector is small, but not when it is large. Consider the following vector:
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(...*/
}
But I can not find a way to find the occurrence of equal ages when the vector has more than 1,000 positions. Can anyone give me a hint how this can be done?
Thank you very much!