class CRand
{
public:
CRand( unsigned seed = time(0) ) ;
int getRandom( int min , int max ) ;
};
CRand::CRand( unsigned seed )
{
srand( seed ) ;
}
int CRand::getRandom( int min , int max )
{
if ( max < 0 )
max = 0 ;
if ( ( min == max ) && 0 == min )
return 0 ;
return rand() % ( max + 1 - min ) + min ;
}
/***
*rand.c - random number generator
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines rand(), srand() - random number generator
*
*******************************************************************************/
/***
*void srand(seed) - seed the random number generator
*
*Purpose:
* Seeds the random number generator with the int given. Adapted from the
* BASIC random number generator.
*
*Entry:
* unsigned seed - seed to seed rand # generator with
*
*Exit:
* None.
*
*Exceptions:
*
*******************************************************************************/
/***
*int rand() - returns a random number
*
*Purpose:
* returns a pseudo-random number 0 through 32767.
*
*Entry:
* None.
*
*Exit:
* Returns a pseudo-random number 0 through 32767.
*
*Exceptions:
*
*******************************************************************************/