Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- find out if neighbours are on or off
- add up the number of neighbours that are on
- */
- neighbours(int** grid, int x, int y)
- {
- int alive = 0, dead = 0, i, j;
- for(j=y-1; j<=y+1; j++)
- {
- for(i=x-1; i<=x+1; i++)
- {
- if(i != miny && grid[i][j]==1)
- alive++;
- else
- dead++;
- }
- if(i != minx && grid[i][j]==1)
- alive++;
- else
- dead++;
- }
- return(alive);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement