c Plus Plus Name

Preview:

DESCRIPTION

c plus plus home work cpp

Citation preview

Its actually fairly easy to write a PRNG. Heres a short program that generates 100 pseudo-random numbers:12345678910111213141516171819202122232425262728293031#include #include using namespace std;unsigned int PRNG(){// our initial starting seed is 5323static unsigned int nSeed = 5323;// Take the current seed and generate a new value from it// Due to our use of large constants and overflow, it would be// very hard for someone to predict what the next number is// going to be from the previous one.nSeed = (8253729 * nSeed + 2396403);// Take the seed and return a value between 0 and 32767return nSeed % 32767;}int main(){// Print 100 random numbersfor (int nCount=0; nCount < 100; ++nCount){cout

Recommended