fork download
  1. #include <stdio.h>
  2.  
  3. #define MAX_SIZE 110
  4.  
  5. int N, M;
  6. int Miro[MAX_SIZE][MAX_SIZE];
  7.  
  8. int move_i[] = { -1, 0, 1, 0};
  9. int move_j[] = { 0, 1, 0, -1};
  10.  
  11. struct queue{
  12. int n, m, count;
  13. };
  14.  
  15. struct queue Q[MAX_SIZE*MAX_SIZE];
  16.  
  17. void func()
  18. {
  19. int front = 0, rear = 0;
  20.  
  21. if(Miro[0][0] == 1)
  22. {
  23. Q[rear].n = 0;
  24. Q[rear].m = 0;
  25. Q[rear].count = 1;
  26. rear++;
  27. }
  28.  
  29. while(front != rear)
  30. {
  31. for(int i=0; i<4; i++)
  32. {
  33. n = Q[front].n + move_i[i];
  34. m = Q[front].m + move_j[i];
  35.  
  36. if(n < 0 || m < 0 || n >= N || m >= M) continue;
  37. if(checker[n][m] == false) continue;
  38. if(miro[n][m] == 1)
  39. {
  40. Q[rear].n = n;
  41. Q[rear].m = m;
  42. Q[rear].count = Q[front].count + 1;
  43. rear++;
  44. }
  45. }
  46.  
  47. front++;
  48. }
  49. }
  50.  
  51. int main(void) {
  52. // your code goes here
  53. scanf("%d", &N, &M);
  54.  
  55. for(int i=0; i<N; i++)
  56. {
  57. for(int j=0; j<M; j++)
  58. {
  59. scanf("%d", &Miro[i][j]);
  60. }
  61. }
  62.  
  63. func();
  64.  
  65. printf("%d", Q[front].count);
  66.  
  67. return 0;
  68. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
4 6
101111
101010
101011
111011
compilation info
prog.c: In function ‘func’:
prog.c:33:4: error: ‘n’ undeclared (first use in this function)
    n = Q[front].n + move_i[i];
    ^
prog.c:33:4: note: each undeclared identifier is reported only once for each function it appears in
prog.c:34:4: error: ‘m’ undeclared (first use in this function)
    m = Q[front].m + move_j[i];
    ^
prog.c:37:7: error: ‘checker’ undeclared (first use in this function)
    if(checker[n][m] == false) continue;
       ^~~~~~~
prog.c:37:24: error: ‘false’ undeclared (first use in this function)
    if(checker[n][m] == false) continue;
                        ^~~~~
prog.c:38:7: error: ‘miro’ undeclared (first use in this function)
    if(miro[n][m] == 1)
       ^~~~
prog.c: In function ‘main’:
prog.c:53:8: warning: too many arguments for format [-Wformat-extra-args]
  scanf("%d", &N, &M);
        ^~~~
prog.c:65:17: error: ‘front’ undeclared (first use in this function)
  printf("%d", Q[front].count);
                 ^~~~~
stdout
Standard output is empty