Solve problem 124 using C++.