ACM (UVa) : 441


// http://uva.onlinejudge.org/external/4/441.html

#include <stdio.h>

int main ()
{
    int k;
    bool blank = false;

    while ( scanf ("%d", &k) && k ) {

        if ( blank )
            printf ("\n");
        blank = true;

        int x [13];

        for ( int i = 0; i < k; i++ )
            scanf ("%d", &x [i]);

        for ( int a = 0; k - a > 5; a++ ) {
            for ( int b = a + 1; k - b > 4; b++ ) {
                for ( int c = b + 1; k - c > 3; c++ ) {
                    for ( int d = c + 1; k - d > 2; d++ ) {
                        for ( int e = d + 1; k - e > 1; e++ ) {
                            for ( int f = e + 1; k - f > 0; f++ ) {
                                printf ("%d %d %d %d %d %d\n", x [a],
                                x [b], x [c], x [d], x [e], x [f]);
                            }
                        }
                    }
                }
            }
        }

    }

    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s