generate all subsets of size k from a set

后端 未结 9 1342
南旧
南旧 2020-12-08 03:30

I want to generate all the subsets of size k from a set.

eg:-say I have a set of 6 elements, I have to list all the subsets in which the cardinality of elements is 3

9条回答
  •  再見小時候
    2020-12-08 04:18

    Here is an Iterative solution :

    #include 
    #include 
    void printer(int locations[],int a[],int r)
    {
        int i;
        for(i=0; i0; i--)
            {
                if(locations[i-1]

提交回复
热议问题