⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mt.h

📁 It s an entire application that uses knowdledge of probabilistic and statistical math to generate an
💻 H
字号:
#include <stdio.h>#include <conio.h>#define NN 624#define M 397#define MATRIX_A 0x9908b0dfUL   /* vectorul a */#define UPPER_MASK 0x80000000UL#define LOWER_MASK 0x7fffffffULstatic unsigned long x[NN]; /* tabloul de n numere */static int mti=NN+1; /* mti==NN+1 inseamna ca  x[NN] nu este initializat *//* initializarea celor NN numere ce se stocheaza in x[NN] */void init_genrand(unsigned long s){  /* modul de initializare a fost sugerat de Donald Knuth*/    x[0]= s & 0xffffffffUL;    for (mti=1; mti<NN; mti++)     {	x[mti] =	    (1812433253UL * (x[mti-1] ^ (x[mti-1] >> 30)) + mti);	x[mti] &= 0xffffffffUL;    }}/* Genereaza un numar aleator intreg din intervalul [0,0xffffffff] */unsigned long genrand_int32(void){    unsigned long y;    static unsigned long v[2]={0x0UL, MATRIX_A};    if (mti >= NN)       { /* generate NN numere simultan */	int j;	if (mti == NN+1)   /* daca init_genrand() nu a fost apelat, */	    init_genrand(5489UL); /* un seed implicit */	for (j=0;j<NN-M;j++)	    {	    y = (x[j]&UPPER_MASK)|(x[j+1]&LOWER_MASK);	    x[j] = x[j+M] ^ (y >> 1) ^ v[y & 0x1UL];	    }	for (;j<NN-1;j++)	{	    y = (x[j]&UPPER_MASK)|(x[j+1]&LOWER_MASK);	    x[j] = x[j+(M-NN)] ^ (y >> 1) ^ x[y & 0x1UL];	}	y = (x[NN-1]&UPPER_MASK)|(x[0]&LOWER_MASK);	x[NN-1] = x[M-1] ^ (y >> 1) ^ v[y & 0x1UL];	mti = 0;    }    y = x[mti++];    /* Operatiile de temperare */    y ^= (y >> 11);    y ^= (y << 7) & 0x9d2c5680UL;    y ^= (y << 15) & 0xefc60000UL;    y ^= (y >> 18);    return y;}/* generator de numere din intervalul [0,1) */double genrand_real2(void){    return genrand_int32()*(1.0/4294967296.0);    /* 4294967296= 2^32 */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -