fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define W 8
  5. #define H 6
  6. char map[H][W]={
  7. {1,1,1,1,1,1,1,1},
  8. {1,0,0,0,0,0,0,1},
  9. {1,0,1,1,1,0,1,1},
  10. {1,0,0,0,0,1,0,1},
  11. {1,0,0,1,0,0,2,1},
  12. {1,1,1,1,1,1,1,1},
  13. };
  14.  
  15. void maze1(int x,int y,int depth){
  16. int i;
  17. for(i=0;i<depth*2;i++){
  18. printf(" ");
  19. }
  20. printf("(%d,%d)",x,y);
  21. if(map[y][x]==0){
  22. printf("\n");
  23. maze1(x+1,y,depth+1);
  24. maze1(x,y+1,depth);
  25. } else if(map[y][x]==1){
  26. printf("X\n");
  27. } else {
  28. printf("OK\n");
  29. exit(0);
  30. }
  31. }
  32.  
  33. int main(void) {
  34. maze1(1,1,0);
  35. return 0;
  36. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
(1,1)
  (2,1)
    (3,1)
      (4,1)
        (5,1)
          (6,1)
            (7,1)X
          (6,2)X
        (5,2)
          (6,2)X
        (5,3)X
      (4,2)X
    (3,2)X
  (2,2)X
(1,2)
  (2,2)X
(1,3)
  (2,3)
    (3,3)
      (4,3)
        (5,3)X
      (4,4)
        (5,4)
          (6,4)OK