Advertisement
Guest User

Untitled

a guest
May 26th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. bool pass(cell gamefield[9][9], int startx,int starty, int endx, int endy)
  2. {
  3. bool up,down,left,right;
  4. gamefield[startx][starty].busy = true;
  5. if ((startx == endx) && (starty == endy)) return true;
  6. else
  7. {
  8. if ((starty>0) && (gamefield[startx][starty-1].busy == false)) up = pass(gamefield,startx,starty-1,endx,endy);
  9. else up = false;
  10.  
  11. if ((startx>0) && (gamefield[startx-1][starty].busy == false)) left = pass(gamefield,startx-1,starty,endx,endy);
  12. else left = false;
  13.  
  14. if ((starty<8) && (gamefield[startx][starty+1].busy == false)) down = pass(gamefield,startx,starty+1,endx,endy);
  15. else down = false;
  16.  
  17. if ((startx<0) && (gamefield[startx+1][starty].busy == false)) right = pass(gamefield,startx+1,starty,endx,endy);
  18. else up = false;
  19.  
  20. return(up || down || left || right);
  21. }
  22. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement