diff --git a/Ch 01. Arrays and Strings/Stringpermutation.c b/Ch 01. Arrays and Strings/Stringpermutation.c new file mode 100644 index 0000000..a3eb1db --- /dev/null +++ b/Ch 01. Arrays and Strings/Stringpermutation.c @@ -0,0 +1,34 @@ +#include +void swap(char *p,char *q) +{ +char temp; +temp=*p; +*p=*q; +*q=temp; +} +void permute(char *a,int l,int r) +{ +int i; +if (l==r) +printf("%s\n", a); +else +{ +for (i=l;i<=r;i++) +{ +swap((a+l),(a+i)); +permute(a,l+1,r); +swap((a+l),(a+i)); +} +} +} +void main() +{ +char str[100]; +printf("Enter the String\n"); +gets(str); +printf("\n"); +int n = strlen(str); +printf("All permutations are :\n"); +permute(str,0,n-1); + +}