int g_comb_count=0;
void combination_Core(char *s,int a[],int i)
{
if(*s=='\0')
{
bool flag=false;
for(int j=0;j<i;j++)
{
cout<<setw(5)<<static_cast<char>(a[j]);
flag=true;
}
if(flag)
{
g_comb_count++;
cout<<endl;
}
}
else
{
combination_Core(s+1,a,i);
a[i++]=*s;
combination_Core(s+1,a,i);
}
}
void combination(char *s)
{
g_comb_count=0;
if(s==NULL)
throw exception("Invalid input");
int len=strlen(s);
int *a=new int[len];
combination_Core(s,a,0);
delete[]a;
cout<<"Count:"<<g_comb_count<<endl;
}
void main()
{
char s[]="abcdef";
combination(s);
system("pause");
}