Ich brauche Hilfe, weil ich nicht sehen kann, wo mein Problem ist. Ich habe Funktion Swapping und es sieht wie folgt aus:Warum Array kopiert wird
public static void swapping(int[] curr, Integer i, Integer j, Integer k, Integer l, int z, int dist) {
int tmp;
int[] tmpCurr = curr;
if (i >= 0 && j >= 0 && k < 0 && l < 0) {
tmp = tmpCurr[i];
tmpCurr[i] = tmpCurr[z];
tmpCurr[z] = tmp;
nodesHM.put(1, tmpCurr);
for(int s = 0; s<tmpCurr.length; s++)
System.out.println(tmpCurr[s]);
tmpCurr = curr;
tmp = tmpCurr[j];
tmpCurr[j] = tmpCurr[z];
tmpCurr[z] = tmp;
nodesHM.put(2, tmpCurr);
for(int s = 0; s<tmpCurr.length; s++)
System.out.println(tmpCurr[s]);
}
}
i, j, k, l mir sagen, was mit z zu tauschen. Also, wenn ich sage, dass etwas -1 ist, bedeutet das, dass ich es nicht tauschen will. Wie es in diesem Fall k und l.
Und ich nenne es aus dem Haupt, wie folgt aus:
public static void main(String[] args) {
swapping(ourStartState, 3, 7, -1, -1, 6, 5);
}
private static final int[] ourStartState = { 1, 2, 3, 4, 5, 6, 0, 7, 8 };
Und es soll mir etwas schreiben wie: 1,2,3,0,5,6,4,7,8 und 1,2 , 3,4,5,6,7,0,8
aber es gibt mir 1,2,3,0,5,6,4,7,8 und 1,2,3,0,5, 6,7,4,8
Wohin gehe ich falsch? Danke
Sie werden falsch von nicht einen Debugger und herauszufinden, genau mit, was falsch läuft – redFIVE
Mögliche Duplikat helfen [Was ist ein Debugger ist und wie es mir Probleme diagnostizieren helfen] (http: //stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) – Raedwald