int expr(void) { ExprNptr = ExprNstack; ExprOptr = ExprOstack; ExprError = FALSE; ExprPeek = -1; return(valof(END)); }
int solve(int rows,int cols, int cur, int tar, int x, int y) { int i; if(rows==1 && cols==1) return valof(x+1,y+1); for(i=1;i<cols;i++) { cur++; if(cur == tar) return valof(x+1,y+i); } for(i=1;i<rows;i++) { cur++; if(cur == tar) return valof(x+i,y+cols); } for(i=cols;i>1;i--) { cur++; if(cur == tar) return valof(x+rows,y+i); } for(i=rows;i>1;i--) { cur++; if(cur == tar) return valof(x+i,y+1); } return solve(rows-2,cols-2,cur, tar, x+1,y+1); }
int exprfind(void) { register int result; register int c; c = exprgch(); switch(c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return(numberget(c)); case '!': result = exprfind(); return(ExprError ? 0 : (result <= 0)); case '-': result = exprfind(); return(ExprError ? 0 : -result); case '(': return(valof(RIGHTP)); case ' ': case '\n': case '\t': case '\0': printf("Expression expected: end of expression found.\n"); ExprError = TRUE; return(0); default: printf("Expression expected; '%c' found: Assumed zero.\n", c); ExprError = TRUE; return(0); } }