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