Add Problem 9 c++ solution