void combination(char str[2][100],int len,int row,int j)
{
static char prn[3];
int i=0,k=0,p=0;
if(j==2)
{
prn[j]='\0';
printf("\n%s",prn);
}
for(p=row;p<len;p++)
{
for(k=0;k<strlen(str[row]);k++)
{
prn[j]=str[row][k];
combination(str,len,p+1,j+1);
}
}
}
call : combination(str,len,0,0);// len = number of words in your eg call will be
combination(str,2,0,0);
On 9/30/12, ~*~VICKY~*~ <[email protected]> wrote:
> Given 'n' arrays each of variable sizes. Write code to print all
> combinations. Each combination contains one element from one array each.
> For eg:
> string str[]={"hello", "how"}
>
> op will be
> hh
> ho
> hw
> eh
> eo
> ew
> lh
> lo
> lw
> lh
> lo
> lw
> oh
> oo
> ow
>
> 15 sets would come, includes repetition.
>
> My approach had bugs and didn't work. Help would be appreciated.
>
>
>
>
> --
> Cheers,
>
> Vicky
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.