#include <stdio.h>

int main()
{
    int i,N;
    int a[49]={0};
    int *p[7]; 
    
    while(1){
        scanf("%d",&N);
        if(N==0) break;
        for(i=1;i<=N;i++){
            scanf("%d",&a[i]);
        }
        for(i=1;i<=6;i++){        
            p[i]=&a[i];
        }
        while(*p[1]!=a[N-5]){
            for(i=1;i<=6;i++){
                printf("%d ",*p[i]);
            }
            printf("\n");
            if(*p[6]!=a[N]) p[6]+=1;
            else if(*p[5]!=a[N-1]) {p[5]+=1; p[6]=p[5]+1;}
            else if(*p[4]!=a[N-2]) {p[4]+=1; p[5]=p[4]+1; p[6]=p[5]+1;}
            else if(*p[3]!=a[N-3]) {p[3]+=1; p[4]=p[3]+1;p[5]=p[4]+1; p[6]=p[5]+1;}
            else if(*p[2]!=a[N-4]) {p[2]+=1; p[3]=p[2]+1;p[4]=p[3]+1;p[5]=p[4]+1; p[6]=p[5]+1;}
            else if(*p[1]!=a[N-5]) {p[1]+=1; p[2]=p[1]+1;p[3]=p[2]+1;p[4]=p[3]+1;p[5]=p[4]+1; p[6]=p[5]+1;}
        }
        for(i=1;i<=6;i++){
            printf("%d ",*p[i]);
        }
        printf("\n");       
        printf("\n"); 
    }
    return 0;
}
Retrieved from http://wiki.zeropage.org/wiki.php/Lotto/김태진
last modified 2021-02-07 05:23:40