Some algorithms in C