Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int nachbar(int x, int y){
- assert(x<=42&&y<=62);
- int n=0;
- switch(1){
- case 1: if(Cell_to_token(help[x][y+1])=='*'){n++;};
- case 2: if(Cell_to_token(help[x+1][y+1])=='*'){n++;;};
- case 3: if(Cell_to_token(help[x+1][y])=='*'){n++;};
- case 4: if(Cell_to_token(help[x+1][y-1])=='*'){n++;};
- case 5: if(Cell_to_token(help[x][y-1])=='*'){n++;};
- case 6: if(Cell_to_token(help[x-1][y-1])=='*'){n++;};
- case 7: if(Cell_to_token(help[x-1][y])=='*'){n++;};
- case 8: if(Cell_to_token(help[x-1][y+1])=='*'){n++;};break;
- }
- return(n);
- //postcondition: this function delivers the number of neighbors of one cell.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement