/* quote from stanford cs106b course reader */
#include <iostream>
#include <string>
using namespace std;
/* Private function prototype */
void ListPermutations(std::string str);
void RecursivePermute(string prefix, string rest);
/* Main function */
int main()
{
ListPermutations("ABC");
return 0;
}
/* Private function implementation */
void ListPermutations(std::string str) {
RecursivePermute("", str);
}
void RecursivePermute(string prefix, string rest) {
if (rest.empty()) {
cout << prefix << endl;
} else {
for (int i = 0; i < rest.size(); ++i) {
string newPrefix = prefix + rest[i];
string newRest = rest.substr(0, i) + rest.substr(i+1);
RecursivePermute(newPrefix, newRest);
}
}
}
08-25
07-22
07-22
07-22