All possible combination code
Hi, I am writing code which write down all possible combinations (of a1,a2,a3,b1,b2,b3,c1,c2,c3 in line of three) in 2d array. Basically the answers suppose to be:
a1b1c1
a1b1c2
a1b1c3
a1b2c1
...
a3b3c3
Actually, in program I don't need a, b, c letters. I need only integers, so the answer suppose to be in 2d array and look like this:
111112113121122123131...333
Here is my program concept. I don't know how to set a, b, c sequence in array.
Code:
public class Main {
public static void main(String[] args) {
double [] [] myArray = new double [1][27];
int a = 0;
int x =
int y =
int z =
for(int j=0; j<3; j++)
{
a++;
myArray[0][x] = a;
for(int i=0; i<3; i++)
{
b++;
myArray[0][y] = b;
int c = 0;
for(int f=0; f<3; f++)
{
c++;
myArray[0][z] = c;
}
for(int p=0; p<myArray[0].length; p++)
{
System.out.println(myArray[0][p]);
}
}
}
Re: All possible combination code
That is all combinations of the alphabet {a,b,c} with the string length set to 3. The code I have written is functional, however I'd like to read what ...