fork download
  1. #include <stdio.h>
  2. #define W 8
  3. #define H 6
  4. char map[H][W]={
  5. {1,1,1,1,1,1,1,1},
  6. {1,0,0,0,0,0,0,1},
  7. {1,0,1,1,1,0,1,1},
  8. {1,0,0,0,0,1,0,1},
  9. {1,0,0,1,0,0,2,1},
  10. {1,1,1,1,1,1,1,1},
  11. };
  12.  
  13. void print_map(){
  14. int i,s;
  15. for(i=0;i<6;i++){
  16. for(s=0;s<8;s++){
  17. if(map[i][s]==1) printf("#");
  18. if(map[i][s]==0) printf(" ");
  19. if(map[i][s]==2) printf("G");
  20. }
  21. printf("\n");
  22. }
  23. }
  24. void maze0(int x,int y,int depth){
  25. int i;
  26. if(map[x][y]==0) {
  27. for(i=0;i<depth*2;i++){
  28. printf(" ");
  29. }
  30. printf("(%d,%d)\n",x,y);
  31. }
  32. if(map[x][y]==1) {
  33. for(i=0;i<depth*2;i++){
  34. printf(" ");
  35. }
  36. printf("(%d,%d)X\n",x,y);
  37. }
  38. if(map[x][y]==2) {
  39. for(i=0;i<depth*2;i++){
  40. printf(" ");
  41. }
  42. printf("(%d,%d)OK\n",x,y);
  43. }
  44.  
  45. }
  46.  
  47. int main(void) {
  48. maze0(2,2,5);
  49.  
  50. return 0;
  51. }
  52.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
          (2,2)X