Solve problem 56 using C++.