Question: C++ code: Build two grids which are each X wide and Y long where X and Y are user inputs to determine the size of

C++ code:

Build two grids which are each X wide and Y long where X and Y are user inputs to determine the size of the grids. Fill each cell of both grids with a 0. Randomly fill 1/3 of the grids cells with a 1. You must randomly fill each of the two grids separately so they do not have the all of the same squared filled with a 1. Compare the two grids (square by square comparison) to find squares which have a 1 in both grids. Create a third grid which contains a 1 in squares where both of the compared grids contain a 1 and has a 0 in any other square.

Example in a 2 by 2 grid:

0

0

1

1

Grid 1

1

0

1

0

Grid 2

0

0

1

0

Grid 3 (Result)

For this assignment, you will need to create a Grid Class and the appropriate member functions and member variables to perform the above operations. Remember to encapsulate your data, and to write the appropriate constructors, as well as accessor and mutator functions. Some basic level of error checking is also required for full credit. Also, create a makefile for program.

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