checkRising is the filthy Criminal
This commit is contained in:
parent
f53f29200e
commit
4286d01786
@ -3,12 +3,21 @@ package part5.aufg2;
|
||||
public class Demo {
|
||||
public static void main(String[] args) {
|
||||
Queenproblem Q = new Queenproblem();
|
||||
Q.setField(new int[]{0, 0, 0, 0, 0, 0, 0, 0});
|
||||
Q.setField(new int[]{2,4,6,8,1,3,5,0});
|
||||
Q.print();
|
||||
System.out.println("=============");
|
||||
Q.solve(0);
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ public class Queenproblem {
|
||||
// 0 means empty
|
||||
// 1-8 is the y position of the Queen
|
||||
int[] field;
|
||||
|
||||
int[][] field2D;
|
||||
public Queenproblem(){
|
||||
this.field = new int[8];
|
||||
}
|
||||
@ -144,10 +144,14 @@ public class Queenproblem {
|
||||
}
|
||||
|
||||
public void solve(int queensPlaced){
|
||||
if (queensPlaced == 7){
|
||||
this.print();
|
||||
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)) {
|
||||
@ -161,5 +165,6 @@ public class Queenproblem {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.print();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user