/*************************************** *********************************/
/* 3. All the arrays of the output strings of a function */
/*************************************** *********************************/
Template <typename T>
Void printvect (vector <t> & S)
{
Typename vector <t >:: iterator beg = S. Begin ();
While (beg! = S. End ())
Cout <* beg ++;
Cout <Endl;
}
Void arrangementrecursive (char * STR, vector <char> & cvect)
{
If (* STR = '\ 0 ')
{
// Print the result
Printvect (cvect );
Return;
}
Int length = strlen (STR );
// Function Change STR, use tempstr, and restore after recursion. At the same time, ensure that the access to showarrangement ("ABC") is not out of bounds.
Char * tempstr = new char [Length + 1];
For (INT I = 0; I <length; ++ I)
{
Strcpy_s (tempstr, Length + 1, STR );
// Exchange the first element with the following element
Swap (tempstr [I], tempstr [0]);
// Stack entry
Cvect. push_back (tempstr [0]);
// All n-1 elements are arranged
Arrangementrecursive (tempstr + 1, cvect );
// The sorting starting with * STR is completed, and the output stack is
Cvect. pop_back ();
}
Delete [] tempstr;
}
Void showarrangement (char * Str)
{
If (! Str)
Return;
// Cvect Save the order to be printed
Vector <char> cvect;
Arrangementrecursive (STR, cvect );
}