Posts

Showing posts from February, 2018

8-Queen Problem in java

Image
public class Queens {     int[] x;     public Queens(int N) {         x = new int[N];     }     public boolean canPlaceQueen(int r, int c) {         /**          * Returns TRUE if a queen can be placed in row r and column c.          * Otherwise it returns FALSE. x[] is a global array whose first (r-1)          * values have been set.          */         for (int i = 0; i < r; i++) {             if (x[i] == c || (i - r) == (x[i] - c) ||(i - r) == (c - x[i]))             {                 return false;             }         }         return true;     }     public void printQueens(int[] x) {         int N = x.length;         for (int i = 0; i < N; i++) {             for (int j = 0; j < N; j++) {                 if (x[i] == j) {                     System.out.print("Q ");                 } else {                     System.out.print("* ");                 }             }             System.out.println();         }        

Introduction of Amit Choudhary

Image
Hello guys, Nice to see you here.I have passed my Msc(Computer Science) in 2018.I Like to Play Chess and Learning new creative Things.