Solution to the MaxProductOfThree problem in C++