#include<iostream>
#define ARR_LEN 5

using namespace std;

int main()
{
    int int_arr[ARR_LEN], k, min, max, x, temp, i;

    for(i=0; i<ARR_LEN; i++)
        cin>>int_arr[i];

    cout<<"Enter k: ";
    cin>>k;
    min = (1<<k)-1;
    max = min<<(ARR_LEN-k);

    for(x=min; x<=max; x=((x+(x&(-x)))|(((x^(x+(x&(-x))))>>2)/(x&(-x)))) )
    {
            temp = x;
            i = 0;
            while(temp)
            {
                if(temp&1)
                    cout<<int_arr[i]<<" ";

                i++;
                temp = temp>>1;
            }
            cout<<endl;
    }
    return 0;
}

-- 
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