fork download
  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5. int N; // 보물지도 사이즈 가로
  6.  
  7. int M; // 보물지도 사이즈 세로
  8.  
  9. int answer = 0;
  10.  
  11. // 내 현재위치 Y
  12.  
  13. int px = 0;
  14.  
  15. int py = 0;
  16.  
  17.  
  18.  
  19. //char arr[700][700];
  20.  
  21. char arr[700][700] = {
  22.  
  23. { 'Y','.','.','.','.','.','V' },
  24.  
  25. { '.','.','I','.','.','.','.' },
  26.  
  27. { '.','.','I','I','I','I','I' },
  28.  
  29. { '.','.','.','.','.','.','.' },
  30.  
  31. { '.','.','.','T','.','.','.' } };
  32.  
  33.  
  34.  
  35. int Move(int *x, int * y)
  36.  
  37. {
  38.  
  39. if (*x - 1 >= 0 && (*x - 1 != 'Z' || *x - 1 != 'I')) { *x -= 1; return 1; }
  40.  
  41. if (*y + 1 < M && (*y + 1 != 'Z' || *y + 1 != 'I')) { *y += 1; return 1; }
  42.  
  43. if (*y - 1 >= 0 && (*y - 1 != 'Z' || *y - 1 != 'I')) { *y -= 1; return 1; }
  44.  
  45. if (*x + 1 < N && (*x + 1 != 'Z' || *x + 1 != 'I')) { *x += 1; return 1; }
  46.  
  47.  
  48.  
  49. return 0;
  50.  
  51. }
  52.  
  53.  
  54.  
  55. void find(int x, int y)
  56.  
  57. {
  58.  
  59. char tmp;
  60.  
  61. if (arr[x][y] == 'T') answer = 1;
  62.  
  63.  
  64.  
  65. tmp = arr[x][y];
  66.  
  67. arr[x][y] = 'Z';
  68.  
  69. if (Move(&x, &y) == 1)
  70.  
  71. {
  72.  
  73. find(x, y);
  74.  
  75. }
  76.  
  77.  
  78.  
  79. }
  80.  
  81.  
  82.  
  83. int main()
  84.  
  85. {
  86.  
  87. int p, q;
  88.  
  89. /*
  90.  
  91. scanf("%d %d", &N, &M);
  92.  
  93.  
  94.  
  95. for (p = 0; p < N; p++)
  96.  
  97. {
  98.  
  99. for(q=0;q<M;q++)
  100.  
  101. {
  102.  
  103. scanf("%c", &arr[p][q]);
  104.  
  105. } //for
  106.  
  107. } //for
  108.  
  109. */
  110.  
  111. N =
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘find’:
prog.c:59:7: warning: variable ‘tmp’ set but not used [-Wunused-but-set-variable]
  char tmp;
       ^~~
prog.c: In function ‘main’:
prog.c:111:2: error: expected expression at end of input
  N =
  ^
prog.c:111:2: error: expected declaration or statement at end of input
prog.c:87:9: warning: unused variable ‘q’ [-Wunused-variable]
  int p, q;
         ^
prog.c:87:6: warning: unused variable ‘p’ [-Wunused-variable]
  int p, q;
      ^
stdout
Standard output is empty