fork download
  1. #include <stdio.h>
  2.  
  3. static unsigned int x = 123456789;
  4. static unsigned int y = 362436069;
  5. static unsigned int z = 521288629;
  6. static unsigned int w = 88675123;
  7.  
  8. unsigned int randint(void) {
  9. unsigned int t;
  10. t = (x ^ (x << 11));
  11. x = y; y = z; z = w;
  12. w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
  13. return w;
  14. }
  15.  
  16. int main(void) {
  17. unsigned int max = 0x56000000u;
  18. unsigned int blocksize = max / 16;
  19. int count[16] = {0};
  20. int i;
  21. for (i = 0; i < 160000; i++) {
  22. #if 0
  23. unsigned int value = randint() % max;
  24. #else
  25. unsigned int value;
  26. int ok = 0;
  27. unsigned int r = (0xffffffffu % max + 1) % max;
  28. do {
  29. unsigned int x = randint();
  30. if (r == 0 || x < 0xffffffff - (r - 1)) { ok = 1; value = x % max; }
  31. } while (!ok);
  32. #endif
  33. count[value / blocksize]++;
  34. }
  35. for (i = 0; i < 16; i++) {
  36. printf("%2d %8d\n", i, count[i]);
  37. }
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
 0     9842
 1    10070
 2    10015
 3     9920
 4    10081
 5     9930
 6    10118
 7    10081
 8    10010
 9    10027
10     9874
11    10075
12     9987
13     9944
14     9969
15    10057