What is the Problem with this code? When we write KKKK the problem is clear then.
//FOP LAB //Jawaad Asim //MTS 41 B //Lab 11 //Task 6 #include <iostream> #include <string> using namespace std; void permutation(string prefix, string str); void do_the_permutation (string permuted_word) { permutation("", permuted_word); } int main () { cout << "\n Q: Perform 4-letter WORD UNSCRAMBLING i.e. List all possible combinations of\n 4-letters in a word. Ex: The word 'TEST' can be unscrambled as TEST,TETS,TSET,\n TSTE,TTSE,TTES,etc?\n"; string word; cout << "\n\tPlease enter a word: "; cin >> word; cout << " "; do_the_permutation(word); cout << "\n\n\t"; system("pause"); return 0; } void permutation(string prefix, string str) { int n = str.length(); if (n == 0) { cout << prefix << "\t "; } else { for (int i = 0; i < n; i++) { permutation(prefix + str.at(i), str.substr(0, i) + str.substr(i+1, n)); } } } In this code when all letters are same we get wrong out put or if any of input is same we also get wrong output. can anyone help me?