Algorithm For C/C++