title: A C++ question about dice probability calculation
body: <p>Write a program to find out the probability of each
  "total value" when several unbiased irregular dices (possibly with different number of
  faces) are thrown at the same time.</p>
  
  <p>When an unbiased dice is thrown, the probability of having different face value should
  be equal. For instance, a typical cubic dice should give a probability of 1/6 for the face
  values 1,2,3,4,5 and 6.
  If two cubic dices were thrown, the total of the face values on the two dices is in range
  [2..12]. However, the probability of each "total value” is not equal. For example, the
  total of 4 is having a probability of 3/36 (for combinations 1+3, 2+2 and 3+3) while
  the probability of a total of 2 is only 1/36 (when both dices give 1).</p>
  
  <pre><code>Sample output as follow: (the one with * are the input from user)
  Input the number of dice(s): *2
  Input the number of faces for the 1st dice: *6
  Input the number of faces for the 2nd dice: *6
  Probability of 2 = 1/36
  Probability of 3 = 2/36
  Probability of 4 = 3/36
  Probability of 5 = 4/36
  Probability of 6 = 5/36
  Probability of 7 = 6/36
  Probability of 8 = 5/36
  Probability of 9 = 4/36
  Probability of 10 = 3/36
  Probability of 11 = 2/36
  Probability of 12 = 1/36
  
  Input the number of dice(s): *5
  Input the number of faces for the 1st dice: *1
  Input the number of faces for the 2nd dice: *2
  Input the number of faces for the 3rd dice: *3
  Input the number of faces for the 4th dice: *4
  Input the number of faces for the 5th dice: *5
  Probability of 5 = 1/120
  Probability of 6 = 4/120
  Probability of 7 = 9/120
  Probability of 8 = 15/120
  Probability of 9 = 20/120
  Probability of 10 = 22/120
  Probability of 11 = 20/120
  Probability of 12 = 15/120
  Probability of 13 = 9/120
  Probability of 14 = 4/120
  Probability of 15 = 1/120
  </code></pre>
  
  <p>I don't actually know how to finish the probability part. I want to have some tips about the method to calculate the problem.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  //Initialise output function
  string output(int num){
    case 1:
      return "st";
      break;
    case 2:
      return "nd";
      break;
    case 3:
      return "rd";
      break;
    default:
      return "th";
  }
  
  
  
  //Roll function
  int roll(int num, int result, int value[20]){
      int dice[num][20];
      for (int i=0; i&lt;num;i++){
          for (int j=1; j&lt;=value[i];j++){
              for (int k=0; k&lt;value[i];k++)
                  dice[i][k]=j;
              }
          }
      }
  }
  
  int main(){
      int number;
      //Initialise the number variable
      cout &lt;&lt;"Input the number of dice(s): ";
      cin &gt;&gt; number;
      cout&lt;&lt;endl;
  
      //Initialise the face of the dice using std::array
      int value[11];
      for (int i=0; i&lt;number; i++){
          cout &lt;&lt; "Input the number of faces for the "&lt;&lt; i+1 &lt;&lt; output(i+1) 
      &lt;&lt;" dice: ";
          cin&gt;&gt;value[i];
      }
  
      //set the base of the probability (multiply), the maxrange (sum) for 
      the dice probability
      int base=1;
      int sum;
      for (int i=0; i&lt;number; i++){
          base = base*value[i];
          sum = sum +value[i];
      }
  
      //Output statements
      if (sum &gt;9){
          for (int i=number; i&lt;10; i++){
              cout &lt;&lt; "Probability of  "&lt;&lt;i&lt;&lt;" = "&lt;&lt;roll(number, i, value);
          }
          for (int i=10; i&lt;=sum;i++){
              cout &lt;&lt; "Probability of "&lt;&lt;i&lt;&lt;" = "&lt;&lt;roll(number, i, value);
          }
      } else {
          for (int i=number; i&lt;=sum; i++){
              cout &lt;&lt; "Probability of "&lt;&lt;i&lt;&lt;" = "&lt;&lt;roll(number, i, value);
          }
      }
  
      return 0;
  }
  </code></pre>