0
Arrays- 2D question
Write a program to place 8 queens on an 8Ă8 chessboard in such a way that 1 Q is to be on each row. Ask the user to enter the columns that contain queens in the 8 rows. The program then places the queens in these columns (1 per row) and prints the board.
3 Answers
0
You can do this by Initializing a 2d array and keep all the elements of array 0 at the time of Initialization. When you put a Queen on any position, replace that 0 by 1.
I think there is another constraint in your problem that No queen should attack each other, otherwise without this constraint your problem should be very trivial. This is a very famous problem in AI called "n - Queens problem". Where n is variable.
0
I did try it but it gave me no solution
0
Could you try to help with the coding please