Home > Back-end >  For help! Simple recursive problem
For help! Simple recursive problem

Time:05-03

1 2 3 4
5 6 7 8
9 10 11 12
Starting from 1 take five steps of several games

# include
# include
Bool charge [3] [5]={false};
Int dir [4], [2]={{0, 1}, {1, 0}, {0, 1}, {1, 0}};
int sum=0;
Void DFS (int index, int x, int y) {
If (index==6) {
Sum++;
return;
}
for (int i=0; I & lt; 4. I++) {
Int newx=x + dir [I] [0];
Int newy=y + dir [I] [1];
If ((! At [newx] [newy]) & amp; & Newx & lt; 4 & amp; & Newx & gt; 0 & amp; & Newy & lt; 5 & amp; & Newy & gt; 0 {
At [newx] [newy]=true;
DFS (index + 1, newx, newy);
At [newx] [newy]=false;
}
}
}
Int main () {
At [1] [1]=true;
DFS (1, 1, 1);
Printf (" % d ", sum);
return 0;
}
The output is 0
What went wrong??
  • Related