I have a dice game where the user inputs a number from 1 to 10000 in the random generator and rolls 5 "dice". I have everything done up to that point. Now for the last part of the code I need to write a function that outputs a report of the best multiple value combination (5 of a kind, 4 of a kind, full house (3 of a kind of one value and 2 of a kind of another), 3 of a kind, two pair (two different 2 of a kind), 2 of a kind, a long straight (5 values in a row), a short straight (4 values in a row) or nothing) along with which dice value gave that combination; ex., 3 of a kind with 6s
I think you can do this through one function but I can't figure it out. Here is what I have so far
@Avilius I'm still going to use the user inputted numbers because that is the specifications for what my assignment calls for.
I want the output to look as such:
Enter seed (1 - 10,000): 27
Using seed of 27
The rolled dice: [1] [3] [3] [5] [5]
The frequencies: [1] [0] [2] [0] [2] [0]
The dice totaled 17
Two pair with 5s and 3s
I believe I could do this with perhaps a for loop and if statement. But I'm not sure how I would start that and set it up. Any ideas?
for (unsigned i = 1; i < frequency.size(); ++i)
std::cout << i << " -> " << frequency[i] << " ";
std::cout << '\n';
You're going to get undefined behavior here.
The dice is has 7 elements, you only use 5. The two integers are going to be of unknown value.
Try:
1 2 3 4 5 6 7 8 9
frequency(6);
std::cout << "The rolled dice: ";
for (unsigned i = 0; i < 6; ++i)
{
int roll = rollDie();
std::cout << '[' << roll << "] ";
++frequency[roll];
}
---------------------
You should add a function that takes the 6 dice that are rolled's values and add them together.
1 2 3 4
int Adder(int val, int val1, int val2, int val3, int val4, int val5)
{
return(val + val1 + val2 + val3 + val4 + val5);
}
For the last line of output just create a function that checks if a number has the same value as another.