fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. int main()
  4. {
  5. int Numbers[31] = { 0 };
  6. const int Max = 6;
  7.  
  8. for( int d1 = 0; d1 < Max; ++d1 )
  9. {
  10. for( int d2 = 0; d2 < Max; ++d2 )
  11. {
  12. for( int d3 = 0; d3 < Max; ++d3 )
  13. {
  14. for( int d4 = 0; d4 < Max; ++d4 )
  15. {
  16. for( int d5 = 0; d5 < Max; ++d5 )
  17. {
  18. for( int d6 = 0; d6 < Max; ++d6 )
  19. {
  20. ++Numbers[d1+d2+d3+d4+d5+d6];
  21. }
  22. }
  23. }
  24. }
  25. }
  26. }
  27.  
  28. std::cout << "Number\tTimesRolled\tPercentage" << std::endl;
  29. const int MaxCombinations = 46656;
  30. for( int i = 0; i < 31; ++i )
  31. {
  32. std::cout << i + 6 << '\t' << Numbers[i] << '\t' <<
  33. std::showpoint << std::setprecision(3) <<
  34. (double)Numbers[i] / MaxCombinations * 100 << '%' << std::endl;
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Number	TimesRolled	Percentage
6	1	0.00214%
7	6	0.0129%
8	21	0.0450%
9	56	0.120%
10	126	0.270%
11	252	0.540%
12	456	0.977%
13	756	1.62%
14	1161	2.49%
15	1666	3.57%
16	2247	4.82%
17	2856	6.12%
18	3431	7.35%
19	3906	8.37%
20	4221	9.05%
21	4332	9.28%
22	4221	9.05%
23	3906	8.37%
24	3431	7.35%
25	2856	6.12%
26	2247	4.82%
27	1666	3.57%
28	1161	2.49%
29	756	1.62%
30	456	0.977%
31	252	0.540%
32	126	0.270%
33	56	0.120%
34	21	0.0450%
35	6	0.0129%
36	1	0.00214%