C++ solution for problem 50