[ create a new paste ] login | about

Link: http://codepad.org/ox9rCH5P    [ 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 bufprinta(int cnt, int *pp)
{
    printf("a[%d] ",cnt);
}
void bufprintb(int cnt, int *pp)
{
    printf("b[%d] ",cnt);
}
void bufprintc(int cnt, int *pp)
{
    printf("c[%d] ",cnt);
}
void superposition(int size, int *p, int sel)
{
    int i, tmp=0;
    for(i=0; i<SIZE; i++){


//세로
if(sel == 2)
{
bufprinta(i, p);
}

if(sel == 1 && i%sel == 0)
{
bufprintc(i, p);
}

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



        if(sel==1)
{

//가로
    bufprint(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
a[0] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 
a[1] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 
a[2] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 

a[0] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 
a[1] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 
a[2] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 

a[0] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 
a[1] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 
a[2] c[0] b[0] [0] c[1] [1] c[2] b[2] [2] 




Create a new paste based on this one


Comments: