I hate my life (fixed it) (wrote 1 instead of i) 😭😭😭😭
This commit is contained in:
parent
9aaeaeed5b
commit
9ff0ded7ea
@ -3,18 +3,8 @@ package part5.aufg2;
|
||||
public class Demo {
|
||||
public static void main(String[] args) {
|
||||
Queenproblem Q = new Queenproblem();
|
||||
Q.setField(new int[]{2,4,6,8,1,3,5,0});
|
||||
Q.print();
|
||||
System.out.println("============= ALL");
|
||||
System.out.println(Q.isPossible(7,8));
|
||||
System.out.println("============= Horiz");
|
||||
System.out.println(Q.checkHorizontal(7));
|
||||
System.out.println("============= Vert");
|
||||
System.out.println(Q.checkVertical(8));
|
||||
System.out.println("============= Rising");
|
||||
System.out.println(Q.checkRisingDiagonal(7,8));
|
||||
System.out.println("============= Falling");
|
||||
System.out.println(Q.checkFallingDiagonal(7,8));
|
||||
Q.setField(new int[]{1,0,0,0,0,0,0,0});
|
||||
Q.solve(0);
|
||||
|
||||
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class Queenproblem {
|
||||
}
|
||||
try {
|
||||
if (this.field[col-1-i] != 0) {
|
||||
if (this.field[col-1-i] == row + 1) {
|
||||
if (this.field[col-1-i] == row+i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -144,14 +144,7 @@ public class Queenproblem {
|
||||
}
|
||||
|
||||
public void solve(int queensPlaced){
|
||||
field2D = make2D();
|
||||
if (queensPlaced == 6){
|
||||
System.out.println("solved 6");
|
||||
}
|
||||
for (int col = 1; col < 9; col++) {
|
||||
if(col == 8) {
|
||||
System.out.println("solving the last one");
|
||||
}
|
||||
if (this.field[col-1] == 0) {
|
||||
for (int row = 1; row < 9; row++) {
|
||||
if (isPossible(row,col)) {
|
||||
|
Loading…
Reference in New Issue
Block a user