algorithm c++