#include <stdio.h>
#include <stdlib.h>
int rand2(int min, int max)
{
static unsigned long long z = 1, d = 0, s = 0, i = 256;
static unsigned char* zz = (unsigned char*)&z, * dd = (unsigned char*)&d, *ss = (unsigned char*)&s;
if ((++i) >= 256) { if (d) free((void*)d); d = (unsigned long long)malloc(8); i = 0; } // 產生隨機堆位址到d
z = z * 17 + 139; // 線性求餘法產生0~256之間的隨機數到z
ss[0] = zz[0] + dd[0] + dd[7] + ss[3]; // 隨機數和堆位址混合到ss
ss[1] = zz[1] + dd[1] + dd[6] + ss[0];
......................
阅读全部 | 2021年11月29日 19:43