problem 42 in c++