inherit
Banned
177116
0
Apr 3, 2012 12:41:06 GMT -8
Sativashark
208
February 2012
sativashark
|
Post by Sativashark on Mar 24, 2012 19:46:07 GMT -8
The program I need to make is basically asking the user to enter how many times they would like to roll the dice, and as a result, the program would output how many times the user rolled each number on the die, like they rolled the number 5 4 times and the percentage of each number rolled. someone
|
|
inherit
1453
0
Nov 19, 2012 12:33:36 GMT -8
kasooi
▒█▐ Rawr ▌█▒
8,242
September 2001
kasooi
|
Post by kasooi on Mar 24, 2012 20:49:47 GMT -8
I would say use the built-in rand() function and then just use a switch to add on to 6 different integer variables and then at the end divide the individual counts by the total. I haven't used C++ in a long time so I'm not going to attempt to post source code but it should be relatively easy
|
|
inherit
143665
wildgoosespeeder wildgoosespeeder wildgoosespeeder
0
Jun 14, 2018 5:59:55 GMT -8
wildgoosespeeder
ProBoards V5 be trippin'. I'm disoriented. :P
4,393
August 2009
wildgoosespeeder
|
Post by wildgoosespeeder on Mar 24, 2012 21:28:09 GMT -8
Things to put in the code:
For loop (for number of times to roll the dice using cin)
srand(time(NULL)); rand() % 6 + 1;
cout the statements if you are outputing to CMD
|
|
inherit
Banned
177116
0
Apr 3, 2012 12:41:06 GMT -8
Sativashark
208
February 2012
sativashark
|
Post by Sativashark on Mar 24, 2012 22:18:41 GMT -8
got it! xD
|
|
inherit
1453
0
Nov 19, 2012 12:33:36 GMT -8
kasooi
▒█▐ Rawr ▌█▒
8,242
September 2001
kasooi
|
Post by kasooi on Mar 24, 2012 22:27:20 GMT -8
Just make sure for counting the number of results you don't use if statements on the results, you want a switch. The two are psuedo-code the same(you can break a switch down into if's), but fundamentally different on a cpu level. If statements rely on cpu branching, switches do not.
|
|