1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
void rollrept() {
int outcomeAmount[5] = {0,0,0,0,0,0};
for (int i = 0; i < 5; i++) {
int roll = rollDie() - 1;
outcomeAmount[roll]++;
cout << "["+roll+"]";
sumOfDice += roll;
}
cout << "\nThe Frequencies: ";
for (i = 0; i < outcomeAmount.size(); i++) {
cout << i + "->" + outcomeAmount[i] + " ";
}
//echo sumOfDie here
//'a' holds the amount each number occured (for example: 1st element of a = amount of
//times one occured in the set of die)
int a[] = {count(outcomeAmount, outcomeAmount+6, 1), count(outcomeAmount,
outcomeAmount+6, 2) ,count(outcomeAmount, outcomeAmount+6, 3),
count(outcomeAmount, outcomeAmount+6, 4), count(outcomeAmount,
outcomeAmount+6, 5), count(outcomeAmount, outcomeAmount+6, 6);
for (i = 0; i < a.size(); i++) {
cout << "\n" + (i+1) + " occured " + a[i] + " times."
}
|