Need help with recursive program.

Hello I need help with a Recursive program that I am writing for my C++ class at the Edmonds community college. Mostly I cannot understand what my professor is asking or how to do what he is asking. This right here is the whole project.
Each week on National Public Radio's Weekend Edition-Sunday there is a puzzle challenge, presented by Will Shortz, puzzle editor for the New York Times. The challenge for January 11, 2004 was:
This numerical puzzle originates from the Turkish Intelligence Foundation sent to Will Shortz by Turkish puzzler Metin Orsel. Start with a certain number on a telephone keypad. Move to another number adjacent to it horizontally, vertically or diagonally. Then move to another number adjacent to that one horizontally, vertically or diagonally. And keep doing this until you have 9 digits. All the digits must be different. That is, you'll use 9 of the 10 digits on the phone including zero (0) and the path must not cross itself. When you're done, the number formed by the first 3 digits plus the number formed by the next 3 digits will equal the/ number formed by the last 3 digits. There's only one path that reaches this solution. What is it?
1 2 3
4 5 6
7 8 9
0
"Phonepad puzzle"

It turns out that there are actually two correct solutions. If you did not have the restriction of no crossed paths, there would be three solutions.

Your task is to write a C++ program which uses recursion to find the three possible solutions. You can then decide on your own which solution should be discarded for having crossing paths. You can accomplish this task in the following manner:
•create a const 10X9 array that represents all of the adjacencies for each digit on the phonepad. That is, each row will start with a digit(0-9), the first row will have in it:
{0,7,8,9,-1,-1,-1,-1,-1}
where the 0 represents the 0 digit on the phone, the 7, 8 and 9 represent the digits adjacent to the 0, and the -1's are used as fill.
In a like manner, the row representing the 5 will contain:
{5,1,2,3,4,6,7,8,9}

Alternately, you can have a 10X10 array of booleans, where the row number represents a digit, and the column number represents possible adjacent digits. Any single element is set to true iff the digit represented by the column is adjacent to the digit represented by the row.

•in main, create the array one_answer[9], which holds the 9 digits of the answer.
•for each of the digits (0-9) set one_answer[0] to the digit and call the recursive function nextdigit.

It would probably be a good idea to define the following four functions:
•void nextDigit(int oneAns[], int place)
where oneAns is the number array and place is a number representing the index of which digit is the last to have been added to the array.
this function calls repeat and, if any digits are repeats of previous digits, exits the function.
If all of the digits have been calculated, calls isSolution to see if the number works as a solution.
Otherwise, it goes through each number in the adjacency array for the current digit, adds it in the next place in the array, and makes a recursive call.


•bool repeat(int oneAns[], int place)
where oneAns is the number array and place is a number representing the index of which digit is being added to the array.
this function goes through the digits up to place and checks to see if any is the same as the digit at place. It immediately returns true if there is a match. Return a false if no match is found.


•bool isSolution(int oneAns[])
where oneAns is the number array .
this function takes the first three digits as an int, adds that to the second three digits as an int and compares the sum to the last three digits as an int. It returns true iff they match.

•void print(int oneAns[])
where oneAns is the number array.
this method prints out the numbers in the form nnn + nnn = nnn.

So far everything seem to be working perfectly except for the next digit function, here is my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <iostream>
using namespace std;

//function headers
void nextDigit(int oneAns[], int place);

bool repeat(int oneAns[], int place);

bool isSolution(int oneAns[]);

void print(int oneAns[]);

void printArray(int oneAns[]);

const int adjacencies[10][9] = { 
{ 0, 7, 8, 9, -1, -1, -1, -1, -1 },
{ 2, 1, 3, 4, 5, 6, -1, -1, -1 },
{ 3, 2, 5, 6, -1, -1, -1, -1, -1 },
{ 4, 1, 2, 5, 8, 7, -1, -1, -1 },
{ 5, 1, 2, 3, 4, 6, 7, 8, 9 },
{ 6, 2, 3, 5, 8, 9, -1, -1, -1 },
{ 7, 4, 5, 8, 0, -1, -1, -1, -1 },
{ 8, 4, 5, 6, 7, 9, 0, -1, -1 },
{ 9, 5, 6, 8, 0, -1, -1, -1, -1 } 
};

int main()
{
	int oneAns[] = { 3, 7, 1, 2, 4, 5, 9, 8, 0, 6 };
	printArray(oneAns);
	nextDigit(oneAns, 0);
	cin.get();
	return EXIT_SUCCESS;
}

bool repeat(int oneAns[], int place)
{
	for (int i = 0; i < place-1; i++)
	{
		if (oneAns[i] == oneAns[place])
		{
			return true;
		}
	}
	return false;
}
bool isSolution(int oneAns[])
{
	int sum = ((oneAns[0] * 100) +(oneAns[1] * 10) + oneAns[2]) +
		((oneAns[3] * 100) + (oneAns[4] * 10) + oneAns[5]);
	if (sum == ((oneAns[6] * 100) + (oneAns[7] * 10) + oneAns[8]))
	{
		return true;
	}
	else
	{
		return false;
	}
}

void print(int oneAns[])
{
	cout << ((oneAns[0] * 100) + (oneAns[1] * 10) + oneAns[2]) << " + " <<
		((oneAns[3] * 100) + (oneAns[4] * 10) + oneAns[5]) << " = " <<
		((oneAns[6] * 100) + (oneAns[7] * 10) + oneAns[8]) << endl;
}

void printArray(int oneAns[])
{
	for (int i = 0; i < 9; i++)
	{
		cout << oneAns[i];
	}
	cout << endl;
}

void nextDigit(int oneAns[], int place)
{
	if (repeat(oneAns, place))
	{
		exit;
	}
	else
	{
		if (isSolution(oneAns))
		{
			// print out the solution
			system("CLS");
			print(oneAns);
		}
		else
		{
			for (int i = 0; i < 9; i++)
			{
				oneAns[i] += adjacencies[place][i+1];
				printArray(oneAns);
			}
			printArray(oneAns);
			nextDigit(oneAns, place + 1);
		}
	}
}

I cant understand what he means by "Add it into the next place in the array" Could someone please tell me what I am doing wrong and point me in the right direction?(Note* please do not lecture me that you wont give the answer or anything like that, I understand that but I you cant even point me in the right direction then what is the point of these forums?).

Topic archived. No new replies allowed.