Algorithm introduction using c++