Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. int nachbar(int x, int y){
  2.     assert(x<=42&&y<=62);
  3.     int n=0;
  4.     switch(1){
  5.         case 1: if(Cell_to_token(help[x][y+1])=='*'){n++;};
  6.         case 2: if(Cell_to_token(help[x+1][y+1])=='*'){n++;;};
  7.         case 3: if(Cell_to_token(help[x+1][y])=='*'){n++;};
  8.         case 4: if(Cell_to_token(help[x+1][y-1])=='*'){n++;};
  9.         case 5: if(Cell_to_token(help[x][y-1])=='*'){n++;};
  10.         case 6: if(Cell_to_token(help[x-1][y-1])=='*'){n++;};
  11.         case 7: if(Cell_to_token(help[x-1][y])=='*'){n++;};
  12.         case 8: if(Cell_to_token(help[x-1][y+1])=='*'){n++;};break;
  13.  
  14.         }
  15.     return(n);
  16.     //postcondition: this function delivers the number of neighbors of one cell.
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement