#include<stdio.h>
#include<conio.h>
void comb(char *,int,int);
char toggle(char);
void main()
{
char list[4]={'t','t','t','t'};
int i=0,n=3;
comb(list,i-1,n);
getch();
}
void comb(char *list,int i,int n)
{
int j,k;
if(i==n)
{
for(j=0;j<=n;j++)
printf("%c",list[j]);
printf(" ");
}
else
{
for(k=0;k<=1;k++)
{
comb(list,i+1,n);
list[i+1]=toggle(list[i+1]);
}
}
}
char toggle(char c)
{
if(c=='t')
return 'f';
else
return 't';
}
#include<conio.h>
void comb(char *,int,int);
char toggle(char);
void main()
{
char list[4]={'t','t','t','t'};
int i=0,n=3;
comb(list,i-1,n);
getch();
}
void comb(char *list,int i,int n)
{
int j,k;
if(i==n)
{
for(j=0;j<=n;j++)
printf("%c",list[j]);
printf(" ");
}
else
{
for(k=0;k<=1;k++)
{
comb(list,i+1,n);
list[i+1]=toggle(list[i+1]);
}
}
}
char toggle(char c)
{
if(c=='t')
return 'f';
else
return 't';
}
thanks for giving this example and also please you can post algorithm immediately
ReplyDeleteThis comment has been removed by the author.
Delete