Question: 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

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 Programming Questions!