# include & lt; stdio.h>
Int a [21] [21]={0}, count=0, m, n;
Int main ()
{
Int x, y;
Void search (int x, int y);
The scanf (" % d % d % d % d ", & amp; M, & amp; N, & amp; X, & amp; Y);
A [x] [y]=1;
A [1] x [x - 2]=1;//will not be able to pass the point of value is set to 1
A [1] x [x + 2]=1;
A [x - 2] [x + 1]=1;
A [1] x [x - 2]=1;
A [x + 1] [x + 2]=1;
A [x + 1] [x - 2]=1;
A [x + 2] [x + 1]=1;
A [1] x [x + 2]=1;
Search (0, 0);
Printf (" % d \ n ", count);//output from (0, 0) to (m, n) points'
}
Void search (int x, int y)
{
If (x> M | | y> N) return;//if x> M or y> N the end of the search
If (x==m& & Y==n) {count++; return ; }//if reach (m, n) this number 1
If (a [x] [y + 1)!=1) search (x, y + 1);//if the right can walk to the right to search
If (a [x + 1] [y]!=1) search (x + 1, y);//if below can walk down the search
}
Every time I feel the method should be yes, down to the right, and why the answer right
CodePudding user response:
The subscript have the opportunity to cross;You enter y with a bit less,
CodePudding user response:
Found the problem, is an obstacle to set has a problem, the subscript should not cross, because I only to the right and down the search, and more than this range will return