📄 rand.h
字号:
#define RANDOM_MAX 0x7FFFFFFFstatic long my_do_rand(unsigned long *value){/* */ long quotient, remainder, t; quotient = *value / 127773L; remainder = *value % 127773L; t = 16807L * remainder - 2836L * quotient; if (t <= 0) t += 0x7FFFFFFFL; return ((*value = t) % ((unsigned long)RANDOM_MAX + 1));}static unsigned long next = 1;int my_rand(void){ return my_do_rand(&next);}void my_srand(unsigned int seed){ next = seed;}#include <time.h>int main(){ int i; my_srand((unsigned)(time(NULL))); for(i=0;i<100;i++) { if(i % 10 == 0) printf("\n"); printf("%d\t",my_rand()); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -