fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. int main(void) {
  6. int i=1, a, b, c, d, top [50], reg [50];
  7. srand(time(NULL));
  8. while (i<19){
  9. top [i]=0;
  10. reg [i]=0;
  11. i++;
  12. }
  13. i=0;
  14. while (i<1000000){
  15. int a = rand() % 6 +1;
  16. int b = rand() % 6 +1;
  17. int c = rand() % 6 +1;
  18. int d = rand() % 6 +1;
  19. reg [a+b+c]++;
  20. if (a<=b&&a<=c&&a<=d){
  21. top [b+c+d]++;
  22. } else if (b<=a&&b<=c&&b<=d){
  23. top [a+c+d]++;
  24. } else if (c<=a&&c<=b&&c<=d){
  25. top [a+b+d]++;
  26. }else{
  27. top [b+c+a]++;
  28. }
  29. i++;
  30. }
  31. i=1;
  32. printf("GREATER 3d6 over 4d6 \n \n");
  33. while (i<19){
  34. printf("%d - %d \n", i, top [i]);
  35. i++;
  36. }
  37. i=1;
  38. printf("EXPECTATION EXPRESSION \n \n");
  39. while (i<19){
  40. printf("%d*%d + ", i, top [i]);
  41. i++;
  42. }
  43. i=1;
  44. printf(" \n SIMPLE 3d6 \n \n");
  45. while (i<19){
  46. printf("%d - %d \n", i, reg [i]);
  47. i++;
  48. }
  49. return 0;
  50. }
Success #stdin #stdout 0.11s 2292KB
stdin
Standard input is empty
stdout
GREATER 3d6 over 4d6 
 
1 - 0 
2 - 0 
3 - 749 
4 - 3072 
5 - 7716 
6 - 16333 
7 - 29300 
8 - 48620 
9 - 69953 
10 - 93404 
11 - 114119 
12 - 129019 
13 - 132663 
14 - 123274 
15 - 100925 
16 - 72329 
17 - 42180 
18 - 16344 
EXPECTATION EXPRESSION 
 
1*0 + 2*0 + 3*749 + 4*3072 + 5*7716 + 6*16333 + 7*29300 + 8*48620 + 9*69953 + 10*93404 + 11*114119 + 12*129019 + 13*132663 + 14*123274 + 15*100925 + 16*72329 + 17*42180 + 18*16344 +  
 SIMPLE 3d6 
 
1 - 0 
2 - 0 
3 - 4634 
4 - 13751 
5 - 27845 
6 - 46561 
7 - 69366 
8 - 97583 
9 - 115696 
10 - 124753 
11 - 124656 
12 - 115432 
13 - 97797 
14 - 69014 
15 - 46463 
16 - 27790 
17 - 14030 
18 - 4629