1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include <stdlib.h>
- int rand_r (unsigned int *seed)
- {
- unsigned int next = *seed;
- int result;
- next *= 1103515245;
- next += 12345;
- result = (unsigned int) (next / 65536) % 2048;
- next *= 1103515245;
- next += 12345;
- result <<= 10;
- result ^= (unsigned int) (next / 65536) % 1024;
- next *= 1103515245;
- next += 12345;
- result <<= 10;
- result ^= (unsigned int) (next / 65536) % 1024;
- *seed = next;
- return result;
- }
|