mardi 17 mars 2015

C++ next_permutation function


Im trying to write a program that will ask you to enter a four letter word. Then you're program will display all the possible four letter combinations based on the given word. Example, you entered the word TEST. Then you're program will display the following : TSTE TTES etc. based on my research and a little bit of googling i created this:



using namespace std;
int main()
std::string s = "";
std::sort(s.begin(), s.end());
do {
std::cout << "Please Enter any Letter" << '\n';
std::cin >> s;
std::cout << " The Permutation is " << s <<'\n' << endl;
} while(std::next_permutation(s.begin(), s.end
}


so when i try to enter a four letter word its just display the letter and permutation doesnt happen. What am i doing wrong here? PS Im still a beginner and a student learning C++ so please explain it clearly TY :)




Aucun commentaire:

Enregistrer un commentaire