## reese27

This is my code below. If i were to enter 2 3 2 3 3 5 4, i were to get
0 0's
0 1's
2 2's
3 3's
1 4's
1 5's
0 6's
0 7's
0 8's
0 9's

``````#include "std_lib_facilities.h"

int main()
{

int num;
vector<int> group;
vector<int> freq;

cout<<"Enter 9 numbers, single digits. \n";
while(cin>>num)
{
group.push_back(num);
}

for(int i=0; i < group.size(); i++)
{
freq[group[i]]++;
}
for (int j=0; j < freq.size(); j++)
{
cout<<""<<freq[j]<<"  "<<j<<"'s. \n";

}
keep_window_open();

}
``````

## firstPerson 761

Something like this :

``````vector<short> cntr(10,0); // 0 through 10 elements initialize to 0
vector<short> value(10,0); // same as above;

for(int i = 0; i < value.size(); i++)
cin >> value[i];

//then you know the value is between the  ranges of 0 to 9, and realize
//that when user enter a number it will match the index, so.

for(int i = 0; i < value.size(); i++)
cntr[ value[i] ] += 1;

//Then print it out.``````

## reese27

thank you for your help the program works, but i was wondering if you could explain to me the for loop parts so that I can understand what is going on if you would be so kind?

## Grn Xtrm 84

The first for loop accepts the user input integers and adds them to the vector. The second for loop adds up the number of individual integers in the vector.