this should work (generate all the combinations of n dice each with m sides)

Crappy and a little ad-hoc, and no sign of a recursive but it works for most counts.
…could do with handling multiple dice types throwdice(2,3,5,6,6,6,6) and maybe extend it to use a file instead of an array in memory(??).
Still it can push out a prodigious amount of numbers.

#include 
#include 
#include 
#include 
using namespace std;

int throwDice(int intDices,int DiceSides);
long dicecount=7;
int MaxSides=9; //3
long nRows=(int)pow(MaxSides,dicecount);

int* history=new int[nRows * dicecount]; //create a very large 1 dimensional array

int sum=0;
int main()
{

  for (int j=0;j
			

Leave a Reply