counting duplicates in c++
问题 Let's say I have an array of ints {100, 80, 90, 100, 80, 60} so I want to count those duplicates and save those counter for later. because each duplicate number should be divided by counter like 100 is duplicated 2 times so they should be 50 each. to find duplicates, I used sort. std::sort(array, array + number); for(int i = 0; i < number; i++) { if(array[i] == array[i+1]) counter++; } and I've tried to make counter array to save them on each num of array. but it didn't work. please give me