fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int default_rand() {
  5. static unsigned int i=3, r[34] = { 0xf3bec5da, 0x991539b1, 0x16a5bce3, 0x6774a4cd,
  6. 0x55928aca, 0xc34a51a2, 0x73b5def3, 0x3e01511e, 0x4e508aaa, 0x61048c05,
  7. 0xf5500617, 0x846b7115, 0x6a19892c, 0x896a97af, 0xdb48f936, 0x14898454,
  8. 0x37ffd106, 0xb58bff9c, 0x59e17104, 0xcf918a49, 0x09378c83, 0x52c7a471,
  9. 0x8d293ea9, 0x1f4fc301, 0xc3db71be, 0x39b44e1c, 0xf8a44ef9, 0x4c8b80b1,
  10. 0x19edc328, 0x87bf4bdd, 0xc9b240e5, 0xe9ee4b1b, 0x4382aee7, 0x535b6b41 };
  11. i = (i+1) % 34;
  12. return (r[i] = r[(i+3)%34] + r[(i+31)%34]) >> 1;
  13. }
  14.  
  15. int main(void) {
  16. int i;
  17. srand(1);
  18. for (i=0; i<1000000; i++) {
  19. if (default_rand() != rand()) {
  20. printf("Mismatch at i=%d\n");
  21. return 0;
  22. }
  23. }
  24. printf("Tested %d values; no errors\n",i);
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.03s 2008KB
stdin
Standard input is empty
stdout
Tested 1000000 values; no errors