// Program described in class on 9/10/21 // Rules can be found in class video, short version here:: // For G[x][y] ... add all neighbors & self to find sum In the next generation, value at [x][y] is...

1 answer below »
Included word document.


// Program described in class on 9/10/21 // Rules can be found in class video, short version here:: // For G[x][y] ... add all neighbors & self to find sum In the next generation, value at [x][y] is sum % 10 == 0 0 sum is under 50 add 3 to current sum between 50 & 150 subtract 3, but can't go below 0 sum over 150 1 Any neighbors outside space are 0's // /* Sample to illustrate rules: A-- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 B-- 4 5 0 7 8 3 4 11 6 0 8 9 16 11 12 13 */ // this code does not work, but shows you how it should be structured #include // establish your sizes using variables or #define // so that it is easy to change; // remainder of code should look at these values int NR = 6; int NC = 6; // fill grid G with random values // use srand(seed); to set the sequence // use % high to restrict the range int fillGrid( int G[][], int seed, int high ) { } // print out the grid void printGrid( int G[][] ) { } // given grid, and an particular (x,y) location // compute the value of that spot in next generation int checker( int arr[][NC],int x, int y ) { } int main() { int A[NR][NC]; fillGrid( A, 38, 20 ); printf("A--\n"); printGrid(A); for (i = __ ; i < __;="" ++i="" )="" {="" for="" (j="__;" j="">< __; ++j ) { b[i][j] = checker( a, i, j ); } } printgrid(b); return 0; } __;="" ++j="" )="" {="" b[i][j]="checker(" a,="" i,="" j="" );="" }="" }="" printgrid(b);="" return="" 0;="">
Answered 2 days AfterSep 17, 2021

Answer To: // Program described in class on 9/10/21 // Rules can be found in class video, short version here::...

Arun Shankar answered on Sep 19 2021
148 Votes
#include
#include
#include
using namespace std;
#define ROWS 3
#define COLS 4
// fill grid G with random values
// use srand(seed); to set the sequence
// use % high to restrict the range
void fillGrid(int G[][COLS], int seed, int high)
{
srand(seed);
for(int i = 0; i < ROWS; i++)
for(int j = 0; j < COLS; j++)
G[i][j] = rand() % high;
}
// print out the grid
void printGrid(int G[][COLS])
{
for(int i = 0; i < ROWS; i++)
{
for(int j =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here