fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7. int i, r = 0, n, t,
  8. a[] = {1, 2, 4, 6, 8, 9, 11, 13, 14, 16, 18, 20, 21, 23, 25, 26, 28, 30};
  9.  
  10. srand(time(NULL));
  11. n = rand() % 1000000;
  12. printf("乱数(10進数)%d\n", n);
  13. while (n)
  14. {
  15. t = n & 0x1f;
  16. for ( i = 0; i < 18 && a[i] != t; ++i);
  17. if (i != 18)
  18. r += 10;
  19. n >>= 5;
  20. }
  21. printf("結果 = % d\n", r);
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
乱数(10進数)422044
結果 =  30