Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Define the term matrix?

Answered: 1 week ago