added cpp solution to problem #16