closest pair algorithm implementation in c