| |
|
|
||||
![]() |
||||||
| |
|
|||||
|
Listing 1.cpp // Pseudo Random Number Generation Example // (c) 1999 Guy W.
Lecky-Thompson #include <stdio.h> { // Choose two large
integers such that unsigned long ulGenerator1;
// Choose a seed value
that is between 1 unsigned long ulSeed = 1024; // Choose a value Max, that represents the highest number that is to be returned unsigned long ulMax = 2048; // Generate a series of 10 numbers for (int i = 0; i < 10; i++) {
// For each iteration,
Multiply Generator1 by ulSeed = ulGenerator1
* ulSeed; // The new seed is
remainder of this value ulSeed = ulSeed %
ulMax; // Return seed as
the random value printf("Iteration
: %d %ld\n",i+1,ulSeed); }
}
|
|
|