Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program has to be written in C programming language Question 1 2D arrays and propagating values! We're going to calculate recursive functions on a

The program has to be written in C programming language

Question 1

2D arrays and propagating values! We're going to calculate recursive functions on a map.

Make a 2D array to store a map. Then each round we calculate a new map based on the old map.

Each round you calculate a new map. Each cell of the new map is sum of the current cell and adjacent cells (up, down, left, right, and self). The sum is modulus 10 so it always between 0 and 9 inclusively.

For example if you have a cell surrounded by 4 neighbors who are all 0, the next round that cell will still be 1, but its 4 neighbors will have at least +1 in their cells. All coordinates not within the map count as 0. So if you are on the top row and no cell can be above your cell you count that value as 0 and it will always be 0. Do not access memory you didn't allocate.

Do not access memory you didn't allocate.

1 0 0 0 0 0 

The next round will be:

1 1 0 1 0 0 

And the next round will be:

3 2 1 2 2 0 

The input format is in integers:

R M N value[0][0] value[0][1] value[0][2] ... value[M-1][N-2] value[M-1][N-1] 

Where R is rounds (iterations) M is height (rows) and N is width (cols)

So for 2 rounds of 3 3 all 0s we would have

2 3 3 0 0 0 0 0 0 0 0 0 

or you can lay it out nicely

2 3 3 0 0 0 0 0 0 0 0 0 

All the numbers are whitespace seperated (spaces or new lines or end of file).

Invalid inputs (not enough, or bad dimensions) should be met with:

Invalid input! 
  • The maximum number of rounds (inclusive) are 32000
  • The maximum dimensions of height or width is 16000

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

Data Analytics Systems Engineering Cybersecurity Project Management

Authors: Christopher Greco

1st Edition

168392648X, 978-1683926481

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago