Added solution to Problem 2 in C++. Fixed formatting.