fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. int main()
  5. {
  6. int Numbers[11] = { 0 };
  7. const int Max= 6;
  8. const int Combinations = 36;
  9.  
  10. for( int d1 = 0; d1 < Max; ++d1 )
  11. {
  12. for( int d2 = 0; d2 < Max; ++d2 )
  13. {
  14. ++Numbers[d1+d2];
  15. }
  16. }
  17.  
  18. std::cout << "Number\tTimesRolled\tPercentage" << std::endl;
  19. for( int i = 0; i < 11; ++i )
  20. {
  21. std::cout << i + 2 << '\t' << Numbers[i] << '\t' <<
  22. std::showpoint << std::setprecision(3) <<
  23. (double)Numbers[i] / Combinations * 100 << '%' << std::endl;
  24. }
  25. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Number	TimesRolled	Percentage
2	1	2.78%
3	2	5.56%
4	3	8.33%
5	4	11.1%
6	5	13.9%
7	6	16.7%
8	5	13.9%
9	4	11.1%
10	3	8.33%
11	2	5.56%
12	1	2.78%