fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define N 6
  5. void u(int d[], int n, int k) {
  6. if (k < N) printf("%d:%d/%d\n", k + 1, d[k], n), u(d, n, k + 1);
  7. }
  8. void h(int d[], int n) { if (n >= 0) d[rand() % N]++, h(d, n - 1); }
  9. void g(int d[], int k) { if (k >= 0) d[k] = 0, g(d, k - 1); }
  10. void f(int n) {
  11. int d[N - 1];
  12. g(d, N - 1);
  13. h(d, n);
  14. u(d, n, 0);
  15. putchar('\n');
  16. }
  17.  
  18. #define SEED 31415926
  19. int main() {
  20. srand(SEED);
  21.  
  22. f(10);
  23. f(100);
  24. f(1000);
  25. f(10000);
  26. f(100000);
  27. return 0;
  28. }
  29. /* end */
  30.  
Success #stdin #stdout 0.02s 1720KB
stdin
Standard input is empty
stdout
1:0/10
2:3/10
3:1/10
4:2/10
5:4/10
6:1/10

1:21/100
2:14/100
3:13/100
4:18/100
5:18/100
6:17/100

1:170/1000
2:150/1000
3:152/1000
4:188/1000
5:172/1000
6:169/1000

1:1690/10000
2:1730/10000
3:1642/10000
4:1714/10000
5:1602/10000
6:1623/10000

1:16696/100000
2:16675/100000
3:16601/100000
4:16793/100000
5:16737/100000
6:16499/100000