my c++ code  for some classic algorithm