a simple program to find out the permutations of all the letters in the word
ex:
abc gives
abc
acb
bac
bca
cba
cab
void swap(char *p,char *q){
char c;
c=*p;
*p=*q;
*q=c;
}
void perm(char *a,int m,int n)
{
if(m==n){
for(int i=0;i<=n;i++)
cout<<a[i];
}
else
{
for(int j=n;j<=m;j++)
{
swap(a[j],a[n]);
perm(a,m,n+1);
swap(&a[j],&a[n]);
}
}
int main()
{
char *a = "haia";
perm(a,strlen(a)-1,0);
getch();
return 0;
}