关于C编写的随机数发生器
来源:百度知道 编辑:UC知道 时间:2024/06/23 18:03:17
请问谁有这个发生器啊?能帮忙给出的话,我给另加50分,谢谢了,我的分数不多,但言出必行!谢谢了!
/* Period parameters */
#define CMATH_N 624
#define CMATH_M 397
#define CMATH_MATRIX_A 0x9908b0df /* constant vector a */
#define CMATH_UPPER_MASK 0x80000000 /* most significant w-r bits */
#define CMATH_LOWER_MASK 0x7fffffff /* least significant r bits */
/* Tempering parameters */
#define CMATH_TEMPERING_MASK_B 0x9d2c5680
#define CMATH_TEMPERING_MASK_C 0xefc60000
#define CMATH_TEMPERING_SHIFT_U(y) (y >> 11)
#define CMATH_TEMPERING_SHIFT_S(y) (y << 7)
#define CMATH_TEMPERING_SHIFT_T(y) (y << 15)
#define CMATH_TEMPERING_SHIFT_L(y) (y >> 18)
class CRandom {
// DATA
unsigned int rseed;
unsigned long mt[CMATH_N]; /* the array for the state vector */
int mti; /* mti==N+1 means mt[N] is not initialized */
// FUNCTIONS
public:
CRandom(void);
unsigned int Random( unsigne