Question: C++ 2D Array program Simulate the percolation of fire through a forest in which the outermost row of trees has ignited. If the forest is

C++ 2D Array program

Simulate the percolation of fire through a forest in which the outermost row of trees has ignited. If the forest is very dense much of the forest will burn and the fire will travel through the entire forest into human-populated areas. If the forest is very sparse, a smaller percentage of trees will catch and the fire will die out before reaching the human boundary. Your goal is to simulate fire in a random 15 x 15 unit forest (one tree possible per unit) with a given density.

This problem uses a two-dimensional array. The forest is populated randomly using the specified density. The burn occurs from the top (row 0) down. A tree ignites in row r column c if and only if there is a burning tree in row r-1 at columns c-1, c, or c+1. The prevailing wind in the forest is from north (first row) to south (last row). Trees do not ignite laterally.

A random double value between 0.0 and 1.0 can be generated using formula: double r = (double)rand( ) / RAND_MAX;

Code should ask the user for the density, randomly populate the forest, displays initial forest, ignite the first row, run the burn, and display the final forest. Report the initial actual percent of trees and after the burn report the percent of trees burned in the fire and whether the fire burned out. Display percentages to three decimals.

Example output:

C++ 2D Array program Simulate the percolation of fire through a forest

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!