STL的next_permutation()求全排列
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
char input[15];
#ifndef ONLINE_JUDGE
freopen("10098.txt", "r", stdin);
#endif
scanf("%d/n", &n);
while (n--)
{
gets(input);
int len = strlen(input);
sort(input, input + len);
do {
cout << input << endl;
} while (next_permutation(input, input + len));
cout << endl;
}
}