#include #include using namespace std; const char vowels[] = {'a','e','i','o','u'}; // 'y' is omitted since it is not always considered a vowel // function object class used for splitting a range of chars into consonants and vowels class Parter { public: bool operator() (char c) { return (find(&vowels[0], &vowels[strlen(vowels)], c) != &vowels[strlen(vowels)]); } }; void main() { char text[] = "String processing is easy using the STL"; int length = strlen(text); cout << "Original text: " << text << endl; reverse(&text[0], &text[length]); cout << "Text reversed: " << text << endl; rotate(&text[0], &text[length/2], &text[length]); cout << "Rotated about middle: " << text << endl; random_shuffle(&text[0], &text[length]); cout << "Text randomly reordered: " << text << endl; *remove(&text[0],&text[length],' ') = '\0'; // terminate purged string so that spaces arent' included length = strlen(text); // find length of new string without spaces cout << "Spaces purged from text: " << text << endl; partition(&text[0], &text[length], Parter()); cout << "Text divided into consonants and vowels: " << text << endl; cout << "Ten permutations of the above string: " << endl; for (int i = 0; i < 10; i++) { next_permutation(&text[0], &text[length]); cout << text << endl; } }