firstly use cpp to solve the task