Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have 2 questions, I wanted to know what the variables i, j, and k were for. The previous experts that helped me put those

image text in transcribedimage text in transcribed

I have 2 questions, I wanted to know what the variables i, j, and k were for. The previous experts that helped me put those variable letters down and got me kind of confused. So I just wanted to know what those variable names meant and what they refer too. Also, can someone explain line 28-65. I know there are comments but if I could get a simpler explanation that would be very helpful as I am still a beginner in c++ and if it could be shortened at all. Below are the code instructions.

image text in transcribedimage text in transcribedimage text in transcribed

Problem Description In the game of chess, a game board has a specified number of rows and columns (usually 8 rows and 8 columns.) A "rook" is a chess game piece that can move across any number of columns in a horizontal direction or any number of rows in a vertical direction (but a rook cannot move diagonally in any way.) This is indicated for one rook in the image below, where the green squares represent possible moves for a rook found at row ' 3 ' and column 'e' Note that, as in the above figure, most chess players number the rows from 1-8, while the columns are labelled with letters by most chess players. As coders, we tend to think about these as rows 0 through 7 and columns 0 through 7 instead. In chess, two game pieces (of any type, but we are only concerned about rooks in this assignment) are said to be attacking each other if a single valid move can land one piece in the same square as another game piece. You will be writing a complete C++ program that checks to see if there exists a pair (or more) of two rooks on a given chess board (that only has rook game pieces on it) that are attacking each other. There is one additional component to this problem - several of the squares on the board have "blocks" in them, and a rook cannot move or see past a block. Your program should: 1. prompt for and read in the name of an input file containing the size of a chess board, the locations of rooks, and the locations of blocks as follows: - the first item in the input file will be a (positive) integer representing the number of rows in the chess board. This value will be no larger than 100. - the second item in the input file will be a (positive) integer representing the number of columns in the chess board. This value will be no larger than 100. - What follows will be a sequence of rows, each containing one character for each column. There are three possible values for each character: - '., which means this is am empty chess board square (that does not contain a block or a rook) - '\#', which means this chess board square is a block - ' R, which means this chess board square contains rook 2. Print out the board, as read from the input file, one row at a time. 3. Print out one of two messages, based on the placement of rooks and blocks on the chess board: - "No two rooks can attack each other" should be printed if no two rooks can attack each other. - "At least two rooks can attack each other" should be printed if two or more rooks can attack each other. For example, suppose the file named input1. data contains the following: 57 chess board has 5 rows and 7 columns ..R.\#R. .R. .\#.\# If you ran your program and specified the above input file (with program output in regular text and input in italics 1 ) then the execution would look like: Please enter the name of an input file: input1.data ..R.\#R. .R..\#.\# R# \#.R\#R \#R\#R\#R\# R..\#..R No two rooks can attack each other

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions