All pastes #458162 Raw Edit

Untitled

public text v1 · immutable
#458162 ·published 2007-04-25 19:12 UTC
rendered paste body
void print(char *a, char *b)
{
char *a1, *b1;
int apos = strlen(a);
int olen = apos;
if ( apos == 0 )
    {
    puts(b);
    return;
    }
a1 = malloc(olen+1);
while ( apos )
    {
    /* construct new a */
    strcpy(a1, a);
    /* remove extra char */
    memmove(a1+apos-1, a1+apos, olen-apos+1);
    /* construct new b */
    b1 = malloc(strlen(b)+2);
    b1[0] = a[--apos];
    strcpy(b1+1, b);
    print(a1, b1);
    free(b1);
    }
free(a1);
}
int main(argc, argv)
{
    print("0123456789","MAN");
}