next_permutation函数生成全排列

好多天以前碰到的,当时懒得写博客,今天没事,记录下吧。

 1 #include <algorithm>
 2 #include <iostream>
 3 #include <cstring>
 4 #include <cstdio>
 5  using  namespace std;
 6  const  int N= 101;
 7  char s[N];
 8  int main()
 9 {
10      int len;
11     gets(s);
12     len=strlen(s);
13     sort(s,s+len);
14     puts(s);
15      while(next_permutation(s,s+len))
16     {
17         puts(s);
18     }
19      return  0;
20 }

你可能感兴趣的:(ext)