Basicamente isso Sandro. Porem o que eu gostaria, era de um método eu que fizesse todas as combinações possíveis (4 = 24 combinações possíveis.).
muito Obrigado.
Com a sua resposta, e mais um pouco que li em outros foruns e livros. finalmente consegui todas as possiveis combinacoes.
abaixo, vou deixar o codigo que fiz, caso alguem tenha a mesma duvida.
//Método recursivo que realiza as trocas de possicoes
public static void permuta(int[][] vet) {
p = new int[vet.length][vet[0].length];
permuta(vet,0);
}
private static void permuta(int[][]vet, int n) {
if (n==vet.length) {
cont++;
imprime();
} else {
// compara se as linhas sao iguais
for (int i=0; i < vet.length; i++) {
boolean achou = false;
for (int j = 0; j < n; j++) {
if (p[j]==vet[i]) achou = true;
}
if (!achou) {
p[n] = vet[i];
permuta(vet,n+1);
}
}
}
}
private static void imprime() {
//impressao das linhas
System.out.println();
System.out.print("(" + cont + ") : \n");
for (int i=0; i < p.length; i++){
int v;
int j;
for(j = 0; j < p[0].length; j++){
System.out.print(p[i][j] + ", ");
}
System.out.println();
}
}
E esse, é o resultado, baseado no vetor que mencionei na pergunta:
(1) :
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
(2) :
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
(3) :
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
(4) :
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
(5) :
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
(6) :
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
(7) :
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
(8) :
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
(9) :
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
(10) :
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
(11) :
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
(12) :
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
(13) :
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
(14) :
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
(15) :
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
(16) :
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
(17) :
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
(18) :
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
(19) :
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
(20) :
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
(21) :
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
(22) :
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
(23) :
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
(24) :
12, 11, 15, 14, 10, 4, 0, 19, 13, 17, 3, 9, 20, 6, 8, 16, 1, 7, 5, 18, 2,
10, 17, 20, 7, 6, 3, 14, 2, 18, 15, 19, 8, 16, 1, 5, 9, 13, 12, 11, 4, 0,
12, 8, 6, 2, 17, 14, 4, 9, 0, 5, 13, 7, 3, 19, 10, 18, 20, 11, 16, 15, 1,
2, 7, 18, 4, 0, 15, 1, 11, 3, 14, 20, 5, 19, 16, 13, 6, 12, 10, 17, 9, 8,