Question: The problem Write a program that inputs two integers n and k, where n>=k. Your program should calculate the number of different ways that k

 The problem Write a program that inputs two integers n and

The problem

Write a program that inputs two integers n and k, where n>=k. Your program should calculate the number of different ways that k bishops could be placed on an nXn chessboard. Structure your program using the backtracking scheme that we have used for the eight queens problem. What needs to be modified is the OK function.

Input

Your main program should loop asking the user for values of n and k.

Output

Each time through the loop, output n, k and the number of configurations. Program Termination The program will terminate if the user enters a value of -1 for n.

k bishops on an nXn chessboard We have previously solved the "N Queens Problem", where, for a given n, we calculated the number of ways to place n queens on an nXn board. This problem concerns "bishops" on the chessboard. What is a bishop? A bishop is a chess piece that controls all the squares on the two diagonals that it can reach Note that a bishop may be either on a white square or a black square. The problenm Write a program that inputs two integers n and k, where n>-k. Your program should calculate the number of different ways that k bishops could be placed on an nXn chessboard Structure your program using the backtracking scheme that we have used for the eight queens problem. What needs to be modified is the "OK" function Input Your main program should loop asking the user for values of n and k. Output Each time through the loop, output n, k and the number of configurations. Program Termination The program will terminate if the user enters a value of-1 for n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!