mardi 6 novembre 2018

Getting the first index of a array does not move

I Insert code and explain the problem:

public static void printArray(int[] v) {
    for (int i = 0; i < v.length; i++) {
        System.out.print(v[i]);
    }
    System.out.println("");
}

public static void main(String[] args) {

    int[] a = new int[]{0, 1, 2, 3, 4, 5, 6};
    int[] b = new int[]{0, 1, 2, 3, 4, 5, 6};

    nextPermutationArray(a);
    printArray(a);
    nextPermutationArray(a);
    printArray(a);
    nextPermutationArray(a);
    printArray(a);
    nextPermutationArray(a);
    printArray(a);

    //IntegerPermutation.permutation(a, a.length);
}

The output can be:

run:

1046532

3415620

3052614

3021564

I want it to be in such a way for example, the important thing is that the index 0 is the first:

run:

0146532

0415623

0352614

0321564




Aucun commentaire:

Enregistrer un commentaire