@ankur, i think 1,2 and 2,1 would be same as set theory.. CMMIW.
following is the code..

#include <stdio.h>
#include <stdlib.h>

void print_comb(int *a, int len)
{
        int tlen = len;
        int i, j, k;
        
        for (i=0;i<5;i++) {
                for (j=i+1; j<4;j++) {
                        printf("%d ", a[i]);
                        k=j;
                        while(tlen-1 > 0) {
                                printf("%d ", a[k]);
                                k++;
                                tlen--;
                        }
                        printf("\n");
                        tlen = len;
                }
        }
}

int main(int argc, char *argv[])
{
        int len = atoi(argv[1]);
        int arr[] = {1,2,3,4};
        print_comb(arr, len);
        return 0;
}


On Tue, Jul 26, 2011 at 1:01 PM, Ankur Garg <[email protected]> wrote:
> Hi
> Dont u think the subsets will also be
> {2,1}
> {3,1}
> {3,2}
> {4,1}
> {4,2}
> {4,3}
> On Tue, Jul 26, 2011 at 11:59 AM, sumit <[email protected]> wrote:
>>
>> Given an array of size n, print all the possible subset of array of
>> size k.
>> eg:-
>> input:
>> a[]={1,2,3,4}, k = 2
>> output:
>> 1,2
>> 1,3
>> 1,4
>> 2,3
>> 2,4
>> 3,4
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to