I am writing a dice game that rolls a dice randomly according to a users input of 1-10000 going into srand. I got through the part where I got the output of the 5 dice numbers 1-6 rolled, but now I want to count the frequencies of each number. For example:
The rolled dice: [3] [3] [1] [1] [3]
The frequencies: 1-> 2 2-> 0 3-> 3 4-> 0 5-> 0 6-> 0
I'm guessing I would use an if statement or for loop to do this. If anyone can help me figure this part out that would greatly appreciated.
void counter(vector<int> & v)
{
for(int i=0; i<v.size(); i++)
{
if(v[i] == 6){
//I dont know what to put here
}
if(v[i] == 5){
//I dont know what to put here
}
if(v[i] == 4){
//I dont know what to put here
}
if(v[i] == 3){
//I dont know what to put here
}
if(v[i] == 2){
//I dont know what to put here
}
if(v[i] == 1){
//I dont know what to put here
}
}
And then how would I output the count of each one after that?
std:: just tells you where it comes from. He's explicitly stating that he's using a function from the standard library. Otherwise, you might see cout and wonder "what the heck is that?".