added c++ solution for problem3