rand0.c 332 B

12345678910
  1. /* rand0.c –– produces random numbers */
  2. /* uses ANSI C portable algorithm */
  3. static unsigned long int next = 1; /* the seed */
  4. unsigned int rand0(void)
  5. {
  6. /* magic formula to generate pseudorandom number */
  7. next = next * 1103515245 + 12345;
  8. return (unsigned int) (next/65536) % 32768;
  9. }