@baghel: The method returns the desire output. But looking for some algo which can do the same.
*Subhransu Panigrahi * *Mobile:* *+91-9840931538* *Email:* [email protected] On Tue, Apr 12, 2011 at 12:08 AM, baghel <[email protected]> wrote: > This solution is incorrect.you are only considering ordered > permutations of all the rotations of the list ignoring random > permutations. > for eg in abcd you are missing random permutation like acbd. > here we need implementation of next_permutation() function of c++. > this <http://wordaligned.org/articles/next-permutation> might be > helpful. > Happy coding > > On Apr 9, 12:13 am, Manish Pathak <[email protected]> wrote: > > #include <stdio.h> > > #include <string.h> > > #include <stdlib.h> > > int fact(int n); > > void main() > > { > > char a[20],st_char; > > static int i,j,k,n,ctr,main_ctr; > > printf("Enter the string : "); > > //gets(a); > > scanf("%s",a); > > > > n=strlen(a); > > > > if(n<=1) > > { > > printf("please enter a valid string "); > > exit(0); > > > > } > > > > //label : > > while(main_ctr<n) //loop till length > > { > > for(i=0;i<=n-2;++i) //loop to print first character of string ex > abc,acb > > { > > ctr=0; > > printf("\n"); > > printf("%c",a[0]); > > for(j=i+1;j<=n-1;j++) //take > > { > > printf("%c",a[j]); > > ctr++; > > } > > > > if(ctr!=n-1) > > { > > for(k=1;k<=i;k++)// print characters that left in above loop ex > > from above i=2 print a[0], then j=3 print a[3], means to print a[1] and > a[2] > > > > { > > printf("%c",a[k]); > > ctr++; > > } > > } > > > > } > > > > st_char=a[0]; //ex for abc string this change as a[0]=b; > > for(i=0;i<=n-2;i++) //a[1]=c; > > a[i]=a[i+1]; //a[2]=a; > > > > a[n-1]=st_char; > > > > main_ctr++;} > > > > printf("\n>>>>>Designed by Manish Pathak<<<<<<<< "); > > > > > > > > > > > > > > > > } > > -- > 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.
