HariboteOS/day25/libc/stdlib/rand.c
2021-05-26 20:44:33 +08:00

13 lines
226 B
C

#include <stdlib.h>
static unsigned long int next = 1;
/**
* rand() implementation from The C Programming Language.
*/
int rand(void) {
next = next * 1103515245 + 12345;
return (unsigned int)(next / 65536) % 32768;
}