Showing posts with label N-Queen Problem. Show all posts
Showing posts with label N-Queen Problem. Show all posts

Thursday, April 14, 2011

N-Queen Problem


import java.io.DataInputStream;  
import java.math.*;  
class nQueens
{
                public static void main(String arg[])
                {
                                int n=0;
                                int x[ ]= new int[8];
                                int count=0;
                                DataInputStream in = new DataInputStream(System.in);
                                System.out.print("\n\t\t\t\tN-Queens Problem\n\n");
                               
                try
                                {
                                    System.out.print("Enter value of n  : ");
                   n = Integer.parseInt(in.readLine());
                                }
                               
                                catch(Exception e) {   System.out.print("I/O Error");   }

                                nqueens(1,n,x,count);