您的位置:首页 > 其它

51nod 1348【next_permutation】

2016-09-13 18:10 218 查看
next_permutation的粗讲来自窝bin博客

两个重载函数,第二个带谓词参数_Comp,其中只带两个参数的版本,默认谓词函数为”小于”.

返回值:bool类型

分析next_permutation函数执行过程:

假设数列 d1,d2,d3,d4……

范围由[first,last)标记,调用next_permutation使数列逐次增大,这个递增过程按照字典序。

next_permutation在algorithm头文件里,可以用它来生成全排列。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const int N=10;

char a
;

int main()
{
int len;
scanf("%s",a);
len=strlen(a);
sort(a,a+len);
printf("%s\n",a);
while(next_permutation(a,a+len))
printf("%s\n",a);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: