Question
CROSSWORD PUZZLE ARRAY C++ QUESTION WRITE CODE IN C++ A crossword puzzle grid is a two-dimensional rectangular array of black and white squares. Some of
CROSSWORD PUZZLE ARRAY C++ QUESTION
WRITE CODE IN C++
A crossword puzzle grid is a two-dimensional rectangular array of black and white squares. Some of the white squares are labeled with a positive number according to the crossword labeling rule. .
The crossword labeling rule identifies squares to be labeled with a positive number as follows.
A square is labeled with a positive number if and only if
- the square is white and
- the square does not have a white square immediately above it, or it does not have a white square immediately to its left, or both. The squares identified by these criteria are labeled with consecutive numbers in row-major order, starting at 1.
The following diagram shows a crossword puzzle grid and the labeling of the squares according to the crossword labeling rule.
This question uses a Square structure that represents an individual square in the puzzle and a Crossword 9x9 two dimensional array that represents a crossword puzzle grid.
Globally declare a structure Square having two fields, a bool called isBlack and an int called num.
Page 1 of 2
CISC 1600 Prof. Kadri
Globally declare a 9x9 bool array called blackSquares. Randomly fill blackSquares with 0's and 1's, where 0 indicates a white square and 1 indicates a black square.
Globally declare a 9x9 array to contain Square structures called Crossword..
Writethefunction bool toBeLabeled(int r, int c) This function returns true if the square indexed by row r, column c in a crossword puzzle grid should be labeled with a positive number according to the crossword labeling rule; otherwise it returns false. The parameter blackSquares indicates which squares in the crossword puzzle grid are black.
Write a fillCrossword function to initialize the crossword puzzle grid such that each element of the Crossword grid should contain a Square object with the appropriate color and number. The number is positive if the square is labeled and 0 if the square is not labeled.
Print the blackSquares array, followed by the puzzle array using the same format as shown below.
indicates a black square.
Challenge: Create a 20 by 20 2D array, then ask the user to enter the number of rows and columns not to exceed 20.
Page 2 of 2
Labeled because no white square above and no white square to the left 4 5 6 8 9 10 Labeled because no white square to the left Labeled because 12 13 14 no white square above 15 16 17 1819 20 21 Unlabeled Labeled because no white square above and no white square to the left 4 5 6 8 9 10 Labeled because no white square to the left Labeled because 12 13 14 no white square above 15 16 17 1819 20 21 UnlabeledStep 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