Problem 2 solved (C++)