fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define m 20
  5. int i=0;
  6. int stackx[m]={0};
  7. int stacky[m]={0};
  8. int spointer=0;
  9. int x=1;
  10. int y=1;
  11.  
  12. void push(){
  13. stackx[spointer]=x;
  14. stacky[spointer]=y;
  15. spointer+=1;
  16. }
  17.  
  18. void success(){
  19. if(x==7 && y==7)
  20. {
  21. printf("성공");
  22. }
  23. }
  24.  
  25. int main(void) {
  26. // your code goes here
  27.  
  28. for(i=0; i<m; i++)
  29. {
  30. stackx[i]=0;
  31. stacky[i]=0;
  32. }
  33.  
  34. int j=0;
  35. int n=8;
  36. int array[n][n];
  37.  
  38. for(i=0; i<n; i++)
  39. {
  40. for(j=0; j<n; j++)
  41. {
  42. if(i==0 || j==0 || i==n-1 || j==n-1)
  43. {
  44. array[i][j]=1;
  45. }
  46. else
  47. {
  48. array[i][j]=rand()%2;
  49. }
  50. printf("%d", array[i][j]);
  51. }
  52. printf("\n");
  53. }
  54.  
  55. do{
  56. if(array[x-1][y]==0)
  57. {
  58. push();
  59. array[x-1][y]=2;
  60. x-=1;
  61. success();
  62. }
  63. else if(array[x-1][y-1]==0)
  64. {
  65. push();
  66. array[x-1][y-1]=2;
  67. x-=1;
  68. success();
  69. }
  70. else if(array[x][y+1]==0)
  71. {
  72. push();
  73. array[x][y+1]=2;
  74. x-=1;
  75. success();
  76. }
  77. else if(array[x+1][y+1]==0)
  78. {
  79. push();
  80. array[x+1][y+1]=2;
  81. x-=1;
  82. success();
  83. }
  84. else if(array[x+1][y]==0)
  85. {
  86. push();
  87. array[x+1][y]=2;
  88. x-=1;
  89. success();
  90. }
  91. else if(array[x+1][y-1]==0)
  92. {
  93. push();
  94. array[x+1][y-1]=2;
  95. x-=1;
  96. success();
  97. }
  98. else if(array[x][y-1]==0)
  99. {
  100. push();
  101. array[x][y-1]=2;
  102. x-=1;
  103. success();
  104. }
  105. else if(array[x-1][y-1]==0)
  106. {
  107. push();
  108. array[x-1][y-1]=2;
  109. x-=1;
  110. success();
  111. }
  112. else if(spointer==0)
  113. {
  114. printf("실패");
  115. }
  116. else
  117. {
  118. spointer-=1;
  119. x=stackx[spointer];
  120. y=stacky[spointer];
  121. }
  122.  
  123. }while(spointer==0);
  124.  
  125. }
  126. return 0;
  127. }
  128.  
  129.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:126:2: error: expected identifier or ‘(’ before ‘return’
  return 0;
  ^~~~~~
prog.c:127:1: error: expected identifier or ‘(’ before ‘}’ token
 }
 ^
stdout
Standard output is empty