A recursive puzzle
You have been given a puzzle consisting of a row of squares each containing an integer, like this:
The circle on the initial square is a marker that can move to other squares along the row. At each step in the puzzle, you may move the marker the number of squares indicated by the integer in the square it currently occupies. The marker may move either left or right along the row but may not move past either end. For example, the only legal first move is to move the marker three squares to the right because there is no room to move three spaces to the left. The goal of the puzzle is to move the marker to the 0 at the far end of the row. In this configuration, you can solve the puzzle by making the following set of moves:
void SolvePuzzle(int start, int squares[]){
if(squares[start]==0)
return;
else{
cout<<squares[start]<<" ";
if(squares[start]%2==0)
return SolvePuzzle( start+squares[start],squares);
else
return SolvePuzzle( start-squares[start],squares);
}
}
int main(){
int arraytest[] = { 3, 6, 4, 1, 3, 4, 2, 5, 3, 0 };
SolvePuzzle(arraytest[0],arraytest);
return 0;
}
I solved this but I need to correct the mistakes in if-statement

You wrote that if the number is even it goes right, whereas you should check if its smaller than size and positive. Then the program shall test both possibilities. There lacks a condition maybe there are several possibilities you probably have to choose the shortest.
You should also add a flag to know if you were already there to avoid loops.