Solves Problems 18 and 67 in C++