algorithm study using c++. reference from 《算法珠玑》