Solve problem 65
Solve problem 35 in C++