Solve problem 32 in C++

Go crazy with auto to see how that feels.