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