[ create a new paste ] login | about

Link: http://codepad.org/snniENVz    [ raw code | output | fork ]

C, pasted on May 21:
#define SIZE 3
#define SEL 3


void bufprint(int cnt, int *pp)
{
    printf(" [%d] ",cnt);
}
void bufprint_sero(int cnt, int *pp)
{
    printf("세로[%d] - ",cnt);
}
void bufprint_x(int cnt, int *pp)
{
    printf("x[%d] ",cnt);
}
void bufprint_y(int cnt, int *pp)
{
    printf("y[%d]   ",cnt);
}

void superposition(int size, int *p, int sel)
{
    int i, tmp=0;
    for(i=0; i<SIZE; i++)
    {

        if(sel == 1 && i%2 == 0)
        {
            //bufprint(i, p);
        }


        //세로
                if(sel == 2)
        {
            p[0]=i;
            bufprint_sero(i, p);
        }


        if(sel==1)
        {
            //가로
                        bufprint_x(p[0], p);    bufprint_y(i, p);
        }
        else
        {
            superposition(size, p, sel-1);
        }
    }
    printf("\n");
}

int main()
{
    int i, buf[SIZE];
    for(i=0; i<SIZE; i++) buf[i]=i;
 
    superposition(SIZE, buf, SEL);
    return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
세로[0] - x[0] y[0]   x[0] y[1]   x[0] y[2]   
세로[1] - x[1] y[0]   x[1] y[1]   x[1] y[2]   
세로[2] - x[2] y[0]   x[2] y[1]   x[2] y[2]   

세로[0] - x[0] y[0]   x[0] y[1]   x[0] y[2]   
세로[1] - x[1] y[0]   x[1] y[1]   x[1] y[2]   
세로[2] - x[2] y[0]   x[2] y[1]   x[2] y[2]   

세로[0] - x[0] y[0]   x[0] y[1]   x[0] y[2]   
세로[1] - x[1] y[0]   x[1] y[1]   x[1] y[2]   
세로[2] - x[2] y[0]   x[2] y[1]   x[2] y[2]   




Create a new paste based on this one


Comments: