AllAlgorithms / c

Implementation of All ▲lgorithms in C Programming Language
https://github.com/AllAlgorithms/c
MIT License
1.56k stars 530 forks source link

Permu #432

Open bca072024 opened 3 months ago

bca072024 commented 3 months ago

program to print permutations of a given Word

include

include

include

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); }