Solve problem 87 using C++.