I have this assigment to do that determines which of three dice are loaded. The dice are actually three C functions called dieA(), diaB(), and dieC()each of which returns an int in the range 1 – 6 when called.
I would have to exercise each of the dice functions and determines which one is “loaded.”
This is my idea of how to make ten throws of die A
- #include
-
"threeDice.h" /* header file */
-
int main()
-
{
-
int j;
-
for ( j=0; j<10; j++ )
-
printf("%2d\n", dieA() );
-
}
I would like to know how I would begin to do this program. I was messing around with the rand() function to replicate the throwing of the dice. I know I need variables for a counter and for the number of rolls.
Any help would be appreciated.
You could design it this way.
Each method uses a different method for generating random numbers(So perhaps you need three different random functions, or try to manipulate the seeds to the calls to the rand() function)
generate say n throws of the die with each of the functions.
you could use three arrays. array a for storing numbers from method dieA(), array b for etc.
Then you need a test for randomness of the numbers runs test etc (whatever is not complicated for you).
so you then just take the values in each of the arrays and test them for randomness. A good test will give you the degree of randomness for each test so that you can say which method produced the least random numbers.
The greater the size of a, the more consistent your results become.