Determine what your base condition (case) is. In this case, your base case would probably be to determine if the present position (x, y) is greater than the ceiling, less than the floor, less than the left wall or greater than the right wall.
Next, you should probably determine if the present position (x, y) is the 'end of maze' character or treasure.
Then determine if the present position (x, y) is the 'start of maze' character.
At this point, I would have my algorithm draw a character in that position if all other conditions have been met. This character would represent that the position has been visited. Later on, you could choose to traverse the coordinates that you have collected and replace this character with a blank space if you choose.
The hard part is done. Now you call the method recursively, this time passing in the new coordinates, once for each direction you want your iterator/solver to go. Ex. if (checkPath(r, c-1) == true) // go west
At which point, you can now change the visited path of the maze to spaces. Ex. maze[r][c] = ' ';
This is the best I can do without giving you the entire answer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…