rand.c 405 B

1234567891011121314151617181920
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Header$ */
  6. #include <stdlib.h>
  7. static unsigned long int next = 1;
  8. int rand(void)
  9. {
  10. next = next * 1103515245 + 12345;
  11. return((unsigned int)(next/(2 * (RAND_MAX +1)) % (RAND_MAX+1));
  12. }
  13. void srand(unsigned int seed)
  14. {
  15. next = seed;
  16. }