Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
645 B
0
Indexable
Never
static boolean c [], h [],cc[], cp[];

    static int x[],soCach = 0;
    public void Try(int i){

    for(int j = 1; j<=8; ++j){

    if(!h[j] && !c[i] &&!cc[j-i+8]&&!cp[i+ j]){

    x[i] = j;

    if(i<8){

    h[j] = true;

    c[i] = true;

    cc[j-i+8] = true;

    cp[i + j] = true;
    
    Try(i+1);

    h[j] = false;

    c[i] = false;

    cc[j-i+8] = false;

    cp[i + j] = false;

    }else{

    ++soCach;

    System.out.print("Cach " + soCach + ": ");

    for(int l = 1; l<x.length; ++l)

    System.out.print(x[l] + " ");

    System.out.println();

    }

    }

    }

    }