fork download
  1. int autoplay(void) {
  2. int i,j,k,change,m;
  3. if (!step()) return 0;
  4. do /* while changing */
  5. for (change = 0, i = 1; i < RWS; ++i)
  6. for (j = 1; j < CLS; ++j)
  7. if (!DETECT(bd[i][j],UNKN)) { /* consider nghbrs of safe cells */
  8. m = cnx(i,j,MINE);
  9. if (cnx(i,j,FLAG) == m) { /* mines appear flagged */
  10. for (k = 0; k < DIM(neighbor); ++k)
  11. if (DETECT(NEIGHBOR(i,j,k),UNKN)&&!DETECT(NEIGHBOR(i,j,k),FLAG)) {
  12. if (DETECT(NEIGHBOR(i,j,k),MINE)) { /* OOPS! */
  13. row = i+neighbor[k].i-1, col = j+neighbor[k].j-1;
  14. return 0;
  15. }
  16. change = 1, CLR_BIT(NEIGHBOR(i,j,k),UNKN);
  17. }
  18. } else if (cnx(i,j,UNKN) == m)
  19. for (k = 0; k < DIM(neighbor); ++k)
  20. if (DETECT(NEIGHBOR(i,j,k),UNKN))
  21. change = 1, SET_BIT(NEIGHBOR(i,j,k),FLAG);
  22. }
  23. while (change);
  24. return 1;
  25. }
  26.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'autoplay':
prog.c:3:8: warning: implicit declaration of function 'step' [-Wimplicit-function-declaration]
   if (!step()) return 0;
        ^
prog.c:5:33: error: 'RWS' undeclared (first use in this function)
     for (change = 0, i = 1; i < RWS; ++i)
                                 ^
prog.c:5:33: note: each undeclared identifier is reported only once for each function it appears in
prog.c:6:23: error: 'CLS' undeclared (first use in this function)
       for (j = 1; j < CLS; ++j)
                       ^
prog.c:7:7: warning: implicit declaration of function 'DETECT' [-Wimplicit-function-declaration]
  if (!DETECT(bd[i][j],UNKN)) { /* consider nghbrs of safe cells */
       ^
prog.c:7:14: error: 'bd' undeclared (first use in this function)
  if (!DETECT(bd[i][j],UNKN)) { /* consider nghbrs of safe cells */
              ^
prog.c:7:23: error: 'UNKN' undeclared (first use in this function)
  if (!DETECT(bd[i][j],UNKN)) { /* consider nghbrs of safe cells */
                       ^
prog.c:8:8: warning: implicit declaration of function 'cnx' [-Wimplicit-function-declaration]
    m = cnx(i,j,MINE);
        ^
prog.c:8:16: error: 'MINE' undeclared (first use in this function)
    m = cnx(i,j,MINE);
                ^
prog.c:9:16: error: 'FLAG' undeclared (first use in this function)
    if (cnx(i,j,FLAG) == m) { /* mines appear flagged */
                ^
prog.c:10:22: warning: implicit declaration of function 'DIM' [-Wimplicit-function-declaration]
      for (k = 0; k < DIM(neighbor); ++k)
                      ^
prog.c:10:26: error: 'neighbor' undeclared (first use in this function)
      for (k = 0; k < DIM(neighbor); ++k)
                          ^
prog.c:11:19: warning: implicit declaration of function 'NEIGHBOR' [-Wimplicit-function-declaration]
        if (DETECT(NEIGHBOR(i,j,k),UNKN)&&!DETECT(NEIGHBOR(i,j,k),FLAG)) {
                   ^
prog.c:13:5: error: 'row' undeclared (first use in this function)
     row = i+neighbor[k].i-1, col = j+neighbor[k].j-1;
     ^
prog.c:13:30: error: 'col' undeclared (first use in this function)
     row = i+neighbor[k].i-1, col = j+neighbor[k].j-1;
                              ^
prog.c:13:28: warning: left-hand operand of comma expression has no effect [-Wunused-value]
     row = i+neighbor[k].i-1, col = j+neighbor[k].j-1;
                            ^
prog.c:16:15: warning: implicit declaration of function 'CLR_BIT' [-Wimplicit-function-declaration]
   change = 1, CLR_BIT(NEIGHBOR(i,j,k),UNKN);
               ^
prog.c:21:15: warning: implicit declaration of function 'SET_BIT' [-Wimplicit-function-declaration]
   change = 1, SET_BIT(NEIGHBOR(i,j,k),FLAG);
               ^
stdout
Standard output is empty