Generate all k-permutations of a set with distinct elements in C (not written by me)