C++ code for Coderbyte problems