Permutation Generator
순열 생성기
void Permutations (char *a, const int k, const int m) {
if( k == m ) {
for(int i = 0; i <= m; i++)
std::cout << a[i] << " ";
std::cout << std::endl;
}
else {
for(int i = k; i <= m; i++) {
swap(a[k], a[i]);
Permutations(a, k + 1, m);
swap(a[k], a[i]);
}
}
}
Reference: Fundamentals of Data Structure in C++ (Horowitz, Sahni, Mehta 저, Silicon Press, 2006)