The problem is to use recursion to count how many boxes are in a room. The trick is each box can have boxes inside of it and each one of those can have even more inside of it. It is supposed to begin by asking "How many unnumbered boxes do you see? " you input the number. Then for each of these it asks how many you see inside i.e. (How many do you see in box #1?" Then for each of the ones inside it will ask "How many do you see inside 1.1? .... 1.2? .... 1.3" and so on. I have tried my best at this but I think it is just outside my understanding of recursion so far, especially keeping track of 1.1 1.2 1.1.1 1.2.1 etc etc. I have some code posted below that can so far count the number of boxes within 1 box but thats as far as I can go. We are allowed to use functions but I do not see where this will help. Any suggestions or pushes in the right direction would be appreciated.

Thanks

-a

Code:int find_boxes(int a, int& t, int pre); void count_boxes(int n); int boxes; int main() { int a; char c; cout << "How many unnumbered boxes do you see? - " ; cin >> a; boxes = a; count_boxes(a); cout<< "There are: " << boxes << " boxes in the room.\n"; cin >> c; } int find_boxes (int ans, int& total, int pre){ int x; if(ans == 0) return total; while (ans != 0){ cout << "How many do you see in box " << pre << "." << ans << ": "; cin >> x; total += x; return find_boxes(x, total, pre+1); ans --; } return total; } void count_boxes(int n){ for ( int i = 1; i <= n; i++){ find_boxes(n-i, boxes, i); } }