HariboteOS/day27/libc/stdlib/rand.c
2021-05-29 23:13:17 +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;
}