hw1 convert to c++