I have an array of integers, for example:
int[][] matrix = new int[][] {
new int[2], // array a,
new int[2], // array b,
new int[3], // array c,
new int[4], // array d,
// ... // array x
};
Now i want to generate all the possible index Combination of select one from each array a, b, c, ... x
This means in the example of: {new int[2], new int[2], new int[3]},I want to get such index combination:
{a[0], b[0], c[0]}
{a[0], b[0], c[1]}
{a[0], b[0], c[2]}
{a[0], b[1], c[0]}
{a[0], b[1], c[1]}
{a[0], b[1], c[2]}
{a[1], b[0], c[0]}
{a[1], b[0], c[1]}
{a[1], b[0], c[2]}
{a[1], b[1], c[0]}
{a[1], b[1], c[1]}
{a[1], b[1], c[2]}
The length of the matrix is unknown, but every array in the matrix has at least 1 elements.
Does anyone have a solution for that?