#include<stdio.h> #include<string.h> int anagram(char S[10],int l,char C[10]) { char D[10]; int j,k,m=strlen(C),i; for(j=0;j<=m;j++) { for(k=m;k>j;k--) D[k]=C[k-1]; D[k]=S[m]; D[m+1]=NULL; for(k=j-1;k>=0;k--) D[k]=C[k]; if((m+1)==l) printf("%s\n",D); else anagram(S,l,D); } return 0;} int main() { char S[10],C[10]; C[0]=NULL; gets(S); printf("\n"); anagram(S,strlen(S),C); return 0; }
Showing posts with label Anagram. Show all posts
Showing posts with label Anagram. Show all posts
Wednesday, 4 July 2012
WAP to return all anagrams from the array of strings. (all possible permutation of a String)
Subscribe to:
Posts (Atom)