PracticeDev/study_cpp/cpp_primer_source_code/Chapter 16/strngstl.cpp

26 lines
680 B
C++
Raw Normal View History

2022-12-20 17:31:11 +08:00
// strgstl.cpp -- applying the STL to a string
#include <iostream>
#include <string>
#include <algorithm>
int main()
{
using namespace std;
string letters;
cout << "Enter the letter grouping (quit to quit): ";
while (cin >> letters && letters != "quit")
{
cout << "Permutations of " << letters << endl;
sort(letters.begin(), letters.end());
cout << letters << endl;
while (next_permutation(letters.begin(), letters.end()))
cout << letters << endl;
cout << "Enter next sequence (quit to quit): ";
}
cout << "Done.\n";
// cin.get();
// cin.get();
return 0;
}