Respuesta :
Answer:
See attachment 1 for code
See attachment 2 for the output of permuting letters of parba
See attachment 3 for the output of permuting letters of arbca
Explanation:
The program was implemented in C
The program uses a recursive function letterpermutation and a swap function to successfully implement the requirement of this question.
The letterpermutation function is defined here
void letterpermutation(char *mystring, int index1, int index2) { Â
This lets the program writes to a file
 FILE *fptr;
This opens the file in an appending mode
 fptr = fopen("q3out.txt","a");
int i;
This checks for unique strings.
if (index1 == index2) {
If found, this appends the string to the text file
  fprintf(fptr,"%s\n",mystring); }
If otherwise
else{ Â
This iterates through the string
for (i = index1; i <= index2; i++) Â {
The swap function is called to swap the characters of the string
 swap((mystring+index1), (mystring+i)); Â
This calls the function, recursively
letterpermutation(mystring, index1+1, index2); Â
This further swaps the characters of the string
swap((mystring+index1), (mystring+i)); Â
} } } Â
The swap function begins here and what it literally does is that it swaps characters of the input string to create a new string
void swap(char *ch1, char *ch2) { Â
char temp; Â
temp = *ch1; Â *ch1 = *ch2; Â *ch2 = temp; }
The main function begins here
int main() { Â
This declares and initializes the string
char mystring[] = "ABCd"; // The string here can be changed
This calls the function to permute the string
letterpermutation(mystring, 0, strlen(mystring)-1); Â
return 0; }