homework by C++