Solve problem 23 using C++.