title: c++ checking an array for a specific range of values?
body: <p>i would like to check an array for a specific range of values.
  ie, the range of values is from 0 --> 9 and the actual array is 50 elements large.</p>
  
  <p>i also want to keep track of how many of each value there is.
  ie, if there are 3 zeroes, 8 ones and 5 two's, then my final vector should look like, 3 8 5.</p>
  
  <p>i was able to solve it with the code below BUT, i realized that my range values needs to be equal to my array size, otherwise it does not check all elements.</p>
  
  <p>is there a better way to do this?</p>
  
  <pre><code>int main() {
  
  int intensityRange = 10;
  int cloudSize = 10;
  
  int cloud [] = {0, 3, 3, 2, 1, 5, 2, 3, 5, 2};
  vector &lt;int&gt; totalGreyValues;
  int k = 0;
  
  for (int i = 0; i &lt; intensityRange; i++) {
     for (int j = 0; j &lt; cloudSize; j++) {
        if (cloud[j] == i) {
           k = k + 1;
           cout &lt;&lt; "   " &lt;&lt; k;
        }
        else
          cout &lt;&lt; "  no match  ";
     }
     totalGreyValues.push_back (k);
     k = 0;
  }
  
  cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; totalGreyValues.size();
  
  for (int h = 0; h &lt; totalGreyValues.size(); h ++)
     cout &lt;&lt; "   " &lt;&lt; totalGreyValues[h];
  
  // values --&gt; 0 1 2 3 4 5 6 7 8 9
  // answer --&gt; 1 1 3 3 0 2 0 0 0 0 
  
  return 0;
  }
  </code></pre>