HariboteOS/day24/libc/stdlib/rand.c
2021-05-25 21:42:25 +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;
}