STL的next_permutation()求全排列 /* coder: ACboy date: 2010-3-19 result: 1A description: UVa 10098 Generating Fast */ #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; } }