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