Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program to determine how many squares a queen can eliminate if it is placed on specified row and column of an 8 by
Write a program to determine how many squares a queen can eliminate if it is placed on specified row and column of an 8 by 8 chess board. The function prototype is as follows:
int getEliminationNumber(int row, int col):
For example, the elimination number of the queen at [4][3] is 27.
The pseudo-code is given as the following:
Set the eliminationNumber to 0
for i = 0 to 7
{
for j = 0 to 7
{
set rowDiff to the absolute value of (row - i)
set colDiff to the absolute value of (col - j)
if (rowDiff is the same as colDiff)
increment eliminationNumber by 1
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started