common algorithm realized by c programming lanangue