answersLogoWhite

0

#include<stdio.h>

#include<stdio.h>

#define NUM_ROWS 100

#define NUM_COLS 100

int gol(int h[][NUM_COLS], int row, int col);

int main()

{

int a[NUM_ROWS][NUM_COLS] = { {0, 0, 0, 0, 0, 0, 0},

{0, 0, 1, 0, 1, 0, 0},

{0, 1, 0, 1, 0, 1, 0},

{0, 0, 1, 0, 1, 0, 0},

{0, 1, 0, 1, 0, 1, 0},

{0, 0, 1, 0, 1, 0, 0},

{0, 0, 0, 0, 0, 0, 0} };

int num_rows= 7;

int num_cols = 7;

int life_test;

life_test = game_of_life(a, num_rows, num_cols);

printf ("%d", &life_test);

return 0;

}

int gol(int h[][NUM_COLS], int row, int col)

{

int i, j;

int a=5;

for( i = 2; i < row; i++)

for( j = 2; j < col; j++)

if (h[i][j-1]==0)

a++;

else

if (h[i-1][j-1]==0)

a++;

else

if(h[i-1][j]==0)

a++;

else

if (h[i-1][j+1])==0)

a++;

{

if (a==4)

h[i][j]= 1;

else

h[i][j]=0; }

return h[i][j];

}

User Avatar

Wiki User

13y ago

What else can I help you with?