c icon indicating copy to clipboard operation
c copied to clipboard

Permu

Open bca072024 opened this issue 1 year ago • 0 comments

program to print permutations of a given Word #include<stdio.h> #include<conio.h> #include<string.h> void permute(char *s,int sp,int ep) { void swap(char *,char *); int i; if (sp==ep) printf("%s\n",s); else { for(i=sp;i<=ep;i++) { swap((s+sp),(s+i)); permute(s,sp+1,ep); swap((s+sp),(s+i)); } } } void swap(char *x,char *y) { char temp; temp=*x; *x=*y; *y=temp; } void main() { char string[20]; int noc; void permute (char *,int,int); printf("\nEnter a string:"); gets(string); noc=strlen(string); permute (string,0,noc-1); }

bca072024 avatar Jul 12 '24 08:07 bca072024