Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a basic c++ program to perform the following task using 2-d array donot use complex coding language use basic and write the whole code

Write a basic c++ program to perform the following task using 2-d array donot use complex coding language use basic and write the whole code
image text in transcribed
1. Each cell or slot of a 2D array Game contains either a 1 or a 0 with 1 representing the presence of some object at that position. Given a 2D array, we need to compute the number of objects in the neighborhood of each cell of the array. The neighborhood of a cell includes the cell itself and the cells surrounding it. Write a C++ function that computes and stores the count of neighbors for each cell of a 2D array called Game passed to it as one of the parameters. This function must store the count of neighbors in a second array called NCounts that is also passed to it as a parameter. Further, you must also assume that the maximum size of each array is 1010 whereas the number of rows and columns to be used in calculations are also passed to the function as parameters. Write down a main() function to test the function written by you. You must have at least 5 test cases for arrays of different sizes and different data. main() function should call an independent function to print the 2D array data. Consider a sample example array Game of size 54 as shown below: After calculating the count of neighbors for each position the NCounts array must contain the required information as follows: Consider another example array Game of size 35 as shown below: After calculating the count of neighbors for each position the NCounts array must contain the required information as follows

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions