Recursive exercises in C++