Count how many times elements in an array are repeated
<p>The program I'm trying to write allows me to enter 10 numbers and it should get tell me Number X is repeated X times and so on.</p>

<p>I've been trying this but the problem is I get the result as follows:</p>

<p>For example...{1,1,1,1,4,6,4,7,4}</p>

<blockquote>
  <p>The number 1 is repeated 4 times</p>
  
  <p>The number 1 is repeated 3 times</p>
  
  <p>The number 1 is repeated 2 times</p>
  
  <p>The number 1 is repeated 1 times</p>
  
  <p>The number 4 is repeated 3 times</p>
  
  <p>The number 6 is repeated 1 times</p>
  
  <p>The number 4 is repeated 2 times</p>
  
  <p>The number 7 is repeated 1 times</p>
  
  <p>The number 4 is repeated 1 times</p>
</blockquote>

<p>The problem is that it checks the next number with the following numbers without skipping it, or without knowing it has written it before</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;
int main() {
    int x[10];
    for (int i=0;i&lt;10;i++) {
        cin&gt;&gt;x[i];
    }

    for (int i=0;i&lt;9;i++) {
        int count=1;
        for (int j=i+1;j&lt;10;j++) { 
            if (x[i]==x[j]) count++;
        }
        cout&lt;&lt;"The number "&lt;&lt;x[i]&lt;&lt;" is repeated "&lt;&lt;count&lt;&lt;" times"&lt;&lt;"\n";
    }
}
</code></pre>