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 10 x 10 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 5 x 4 as shown below: 0001 0001 0 1 10 0 1 10 0 000 After calculating the count of neighbors for each position the NCounts array must contain the required information as follows: 0022 1243 2443 2 442 1 221 Consider another example array Game of size 3 x 5 as shown below: 11110 00000 01110 After calculating the count of neighbors for each position the NCounts array must contain the required information as follows: 23321 25642 2 3 2 1 1

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please written by computer source

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

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 10 x 10 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 5 x 4 as shown below:
0001
0001
0110
0110
00 00
After calculating the count of neighbors for each position the NCounts array must contain the
required information as follows:
0022
1243
2
2 442
1 221
Consider another example array Game of size 3 x 5 as shown below:
11110
00000
01110
After calculating the count of neighbors for each position the NCounts array must contain the
required information as follows:
23321
25642
1 2 321
Transcribed Image Text: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 10 x 10 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 5 x 4 as shown below: 0001 0001 0110 0110 00 00 After calculating the count of neighbors for each position the NCounts array must contain the required information as follows: 0022 1243 2 2 442 1 221 Consider another example array Game of size 3 x 5 as shown below: 11110 00000 01110 After calculating the count of neighbors for each position the NCounts array must contain the required information as follows: 23321 25642 1 2 321
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education