complete 1004.cpp