Orders c++生成全排列
2012-08-24 20:00
239 查看
/*将源字符串的顺序改变为升序,课生成字典序上升的全排列。*/ #include<stdio.h> #include<string.h> #include <algorithm> using namespace std; int cmp(const void *a,const void *b) { return *(char *)a-*(char *)b; } int main() { int i; char a[300]; while(scanf("%s",a)==1) { int len=strlen(a); qsort(a,len,sizeof(a[0]),cmp); do { for(i=0; i<len; i++) printf("%c",a[i]); printf("\n"); } while (next_permutation(a,a+len)); } return 0; }
相关文章推荐
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 生成8位26个字母和数字的全排列(密码字典,密钥)c++代码(非递归高效直接)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- C++中rand()函数生成随机数
- 用StartUML生成GoF设计模式类图与代码(c++)
- 【C/C++】automake生成动态链接库
- Effective c++学习笔记——条款6,不想自动生成函数,要明确拒绝
- google竞赛题SecretSum的另一种C++解法, 使用递归生成代替循环 -- 2
- C++文本查询程序 C++Primer练习12.28 使用vector,map,set容器保存来自文件的数据并生成查询结果
- C++中默认构造函数的生成(哪些情况会产生默认构造函数)
- C++调用C#生成的dll
- C++ QRcode 二维码生成
- C++生成不重复的随机数