生成全排列

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <string>
 4 
 5 using namespace std;
 6 
 7 int main()
 8 {
 9     string str;
10     cin >> str;
11     sort(str.begin(), str.end());
12     cout << str << endl;
13     while (next_permutation(str.begin(), str.end()))
14     {
15         cout << str << endl;
16     }
17     return 0;
18 }
 1 #include <cstdio>
 2 #include <algorithm>
 3 #include <cstring>
 4 #define MAX 100
 5 
 6 using namespace std;
 7 
 8 int main()
 9 {
10     int length;
11     char str[MAX];
12     gets(str);
13     length = strlen(str);
14     sort(str, str + length);
15     puts(str);
16     while (next_permutation(str, str + length))
17     {
18         puts(str);
19     }
20     return 0;
21 }
原文地址:https://www.cnblogs.com/--lr/p/7240698.html