Kaum ist ein Problem gelöst kommt schon das nächste... und ich finde meinen Fehler einfach nicht...
zunächst einmal dient das Programm dazu ein Nonogramm zu lösen.
mein 10x10 test nonogramm wird in 8 Durchläufen ohne Probleme gelöst, jedoch kann ich nicht davon ausgehen, dass es jedes nonogramm lösen kann, deswegen möchte ich sobald sich keine Änderung mehr ergibt die schleife abbrechen. Dies wollte ich durch einen einfachen vorher nachher vergleich bei jedem Durchlauf realisieren...
Eigentlich will ich ja nur einen ganz simplen vergleich von 2 Zweidimensionalen Arrays machen von denen ich anfangs zumindest weiß das sie sich unterscheiden...
jedoch bekomme ich bei dem vergleich heraus das sie identisch sind...
um das zu veranschaulichen hier die meines Erachtens wichtigen Programmteile:
hier gibt mir seltsamerweise Java für X[j] und Y[j] exact die selben werte aus, obwohl test anfangs mit nullen gefüllt sein müsste (weil das erste B was ich übergebe noch keine werte gespeichert hatt) und B 100% bei jedem durchlauf bis zur 8. wiederholung jedesmal verändert wird...
von System.out.print bekomme ich folgendes: (wenn ich den break entferne)
das erscheint mir doch sehr seltsam da ich "test" 100%ig nur an der einen stelle ändere bevor ich etwas an B mache... :bahnhof:
Mein Programm funktioniert zwar auch so...
ich würde aber schon gerne abbrechen sobald keine Änderung mehr stattfindet...
zunächst einmal dient das Programm dazu ein Nonogramm zu lösen.
mein 10x10 test nonogramm wird in 8 Durchläufen ohne Probleme gelöst, jedoch kann ich nicht davon ausgehen, dass es jedes nonogramm lösen kann, deswegen möchte ich sobald sich keine Änderung mehr ergibt die schleife abbrechen. Dies wollte ich durch einen einfachen vorher nachher vergleich bei jedem Durchlauf realisieren...
Eigentlich will ich ja nur einen ganz simplen vergleich von 2 Zweidimensionalen Arrays machen von denen ich anfangs zumindest weiß das sie sich unterscheiden...
jedoch bekomme ich bei dem vergleich heraus das sie identisch sind...
um das zu veranschaulichen hier die meines Erachtens wichtigen Programmteile:
Java:
int B[][] = new int[b][h];//Nonogramm
int test[][] = new int[b][h];//vergleichswerte
Java:
for (int j=0; j<10; j++)
{
test = B; //B in test speichern
gemeinsam(S,true); //in allen variatinen gleiche Felder Finden
gemeinsam(Z,false);
clean(S,true); //durch festgelegte felder herausfallende Lösungen bereinigen
clean(Z,false);
//System.out.println("Spalten:");
//for (int i=0;i<b;i++){System.out.print(" : " + S.get(i).size());}System.out.println("");
//System.out.println("Zeilen:");
//for (int i=0;i<h;i++){System.out.print(" : " + Z.get(i).size());}System.out.println("");
if (!anders(test, B)){break;} //Test auf veränderung von B beim letzten Durchlauf
}
Java:
private boolean anders (int X[][], int Y[][])
{
boolean anders = false;
label:
for (int i=0; i<X.length; i++)
{
for (int j=0; j<X[i].length; j++)
{
System.out.print(X[i][j] + " " + Y[i][j] + " | ");
if (X[i][j] != Y[i][j]) {anders = true; break label;}//Vergleichen von test und B
}
}
System.out.println(anders);
return anders;
}
von System.out.print bekomme ich folgendes: (wenn ich den break entferne)
Code:
0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 2 2 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 1 1 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 1 1 | 0 0 | 0 0 | 1 1 | 1 1 | 1 1 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 1 1 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 2 2 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 0 0 | 0 0 | 0 0 | 0 0 | 1 1 | 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