finish exercise 3.13 of c++ primer