ACM (TJU) : 1134


// http://acm.tju.edu.cn/toj/showp1134.html

#include <stdio.h>

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

    while ( scanf ("%d", &k) && k ) {
        int s [13];

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

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

        for ( int a = 0; a < k; a++ ) {
            for ( int b = a + 1; b < k; b++ ) {
                for ( int c =  b + 1; c < k; c++ ) {
                    for ( int d = c + 1; d < k; d++ ) {
                        for ( int e = d + 1; e < k; e++ ) {
                            for ( int f = e + 1; f < k; f++ ) {
                                printf ("%d %d %d %d %d %d\n",
                                s [a], s [b], s [c], s [d], s [e], s [f]);
                            }
                        }
                    }
                }
            }
        }
    }

    return 0;
}

4 thoughts on “ACM (TJU) : 1134

  1. #include <iostream>
    #include <string>
    #include <algorithm>
    using namespace std;
    
    void print(int n, int taken, int current, int data[], int takens[])
    {
        if(taken == 6) {
            printf("%d %d %d %d %d %d\n",takens[0],takens[1],takens[2],takens[3],takens[4],takens[5]);
    		return;
    	}
    	
    	if(current > n) 
            return;
    
    	takens[taken] = data[current];
    
    	print(n,taken+1,current+1,data,takens);
    	print(n,taken,current+1,data,takens);
    }
    
    
    int main(){
    
    	int datas[15], n;
    	int takens[15];
    	int flg=false;
    	
    	while(1){
    	    scanf("%d",&n);
    		
    		if(n == 0) 
                return 0;
    		
    		if(flg) 
                printf("\n");
                
    		for(int i=0;i<n;i++)
    			scanf("%d",&datas[i]);
    			
    		sort(datas,datas+n);
    		print(n-1,0,0,datas,takens);
    		flg=true;
    	}
    }
    
  2. Shahab Vai,

    Kto gula ques ase

    bool first=false blte ki bjhae?

    if ( first )
    17. printf (“\n”);
    18. first = true;
    19.

    eta die ki kora hoise? Eta eto easy chilo othocho mthae e asheni.

    tbe saidul vai er code ta bjhini

  3. bool (Boolean) holo ekta data type.
    for example, int (integer) ekta data type.
    integer data type a, -2147483648 to 2147483647 porjonto number rakha jay.
    Boolean data a, shudhu ‘true’ r ‘false’ rakha jay.

    question a last er dike ekta line ase :
    “Do not put a blank line after the last test case.”
    amar algorithm holo,
    before each case, a blank line will be printed, except for first case.
    so, prothom a first = false
    tarpor theke first = true
    mane, prothom case a blank line print dibe na, tarpor theke dibe

    prothom a ensure korte hobe je, tmr matha ase kina ?
    jodi thake, thaole sheta khatao, mane chesta korte thako
    ekdin na ekdin shofol hoba .. inshaAllah 🙂

    saidul vai er code na bujle oke jigesh koro
    shobai amr moto code korte pare na .. eta tomare buzte hobe 😛
    by the way, without written permission tumi amago code dekhtaso ken !

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