vendredi 26 février 2016

How to group like numbers using c++

So I have written a program to simulate the sum of 10,000 dice rolls and output the results. Now I need to group together all the duplicate numbers and see how many times each one was rolled.

for (int totalrolls = 0; totalrolls < 10000; totalrolls + 1) {
    int dice1 = rand() % 6 + 1;//1st roll
    int dice2 = rand() % 6 + 1;//2nd roll
    int sumtotal = dice1 + dice2;//Sum of the two dice 
    cout << "Sum of dice rolls " << sumtotal << endl;
}

Here is the code I have written for the first part. maths is not really my strong suit so I would appreciate any method that can help me solve this problem.




Aucun commentaire:

Enregistrer un commentaire