Adding c++ solution to problem 1