POJ2245

 摘要:枚舉,暴搜^_^

 

#include <iostream>
using namespace std;

const int SIZE = 12;
int input[SIZE] = {0};
int k;

   
int main()
{
    int temp = 1;
    while( cin >> k )
    {
        if( k == 0 )
        {
            break;
        }
        if( temp++ > 1)
        {
            cout << endl;
        }   
        for(int i=0; i<k; i++)
        {
            cin >> input[i];
        }
        for(int i=0; i<=k-6; i++)
        {
            for(int j=i+1; j<=k-5; j++)
            {
                for(int o=j+1; o<=k-4; o++)
                {
                    for(int p=o+1; p<=k-3; p++)
                    {
                        for(int q=p+1; q<=k-2; q++)
                        {
                            for(int s=q+1; s<=k-1; s++)
                            {
                                cout << input[i] << " " << input[j] << " " << input[o] << " " << input[p] << " " << input[q] << " " << input[s] << endl;
                            }
                        }
                    }
                }
            }
        }

        /*   
        unsigned int max_value = 0;
        unsigned int min_value = 0x3f;
       
        for(int i=k-1; i>=k-6; i--)
        {   
            max_value += (1 << i );
        }
               
        for(unsigned int i=max_value; i>=min_value; i--)
        {
            int array[13] = {0};
            int index = 0;   
            for(int j=k-1; j>=0; j--)
            {
               
                if( (i & (1 << j)) != 0  )
                {
                    array[index++] = input[k-j-1];
                }   
            }
       
            if( index == 6 )
            {
                for(int j=0; j<6; j++)
                {
                    cout << array[j] << " ";
                }
                cout << endl;   
            }
        }
        */
    }

    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章