I have this small program that simulates dice rolls using random numbers. It does 1 million rolls and outputs the results for 1, 10, 100....., 1000000. The way my code is structured right, the program starts by outputting the results for 1 roll, then does 9 other rolls and outputs the results again. I would like to make it so all the rolls are done before outputting anything, because right now I'm basically stopping every loop to check if a condition is met or not and I believe this is somewhat unrecommended. How could I make it so the output code is outside the random loop ?
If you don't want your output code inside the loop, then you just put it outside.XD
The whole would like this:
Start with a for-loop doing 1000000 rolls. After it is done, take average and output.
I might be overcomplicating things here in my head, but I just don't see how I could easily make the program output the results for 1, 10, 100, etc.. up to 1 million.
The differents output screens are to be always at the same position, making the illusion the numbers are adding up (with a _getch() in between).
I just don't see how I could easily make the program output the results for 1, 10, 100, etc.. up to 1 million.
How about this:
1 2 3 4 5 6 7 8
//Mod = 1; // do this before the start of the for loop instead
if (Nb % Mod == 0)
{
Mod *= 10;
gotoxy(1,1);
cout << "Essaie avec " << Nb << " lancer(s):";
// etc.