// Dave Goldsmith // Redwood High School // C++ Computer Programming // November 21, 1999 // Recursion5.cpp /* This program demonstrates how a recursive approach can be used to design a function to display every possible permutation of letters in a word entered by the user. */ #include // Required for 'cin' and 'cout' #include // Required for 'apstring' #include // Required for 'apstring' void Swap(char & letA, char & letB) // This function takes two char variables // (letA, letB) and interchanges (swaps) them. { char temp; // Temporary variable used during swap temp = letA; letA = letB; letB = temp; } void Permutations(apstring & mix, int n) // This function returns every possible combination // (permutation) of an apstring (scrambled). { if (n <= 1) // Base case cout << mix << endl; else for (int i=0; i