finish ex9.cpp