Q:

Combination C code for a random set of integers

I have a random set S={3,12,15,24,33,40} and I need to generate subsets of size 3 from this set.Most of the examples and explanations regarding combination involved a set of increasing and ordered values like S1={1,2,3,4,...n}. Using the combination formula,I found that the number of possible combinations is 20 but can't figure out how to generate that list in C. 
What if the set is random like S above and how do I get the possible list without duplicates in C? 
Thanks.

A:

Use the algorithms you have seen that have increasing, ordered values and simply replace those with the values in your list.
For example, the combinations (0-indexed) would be:
0, 1, 2
0, 1, 3
0, 1, 4
...
...

Then have an array with your numbers
int array[] = { ...values... };

and change the combinations to:
array[0], array[1], array[2]
array[0], array[1], array[3]
...
...

