字符串的全排列 递归
2016-03-11 16:36
351 查看
/* description: 字符串的全排列 来自<<编程之法>> author: JasonZhou date: 2016-03-11 */ #include <iostream> using namespace std; static int count=0; //递归方法 void CallAllPermutation(char* perm,int from,int to) { if (to<1) { return; } if (from==to) { cout<<++count<<":\t"; for (int i=0;i<=to;i++) { cout<<perm[i]; } cout<<endl; } else { for (int j=from;j<=to;j++) { swap(perm[j],perm[from]); CallAllPermutation(perm,from+1,to); swap(perm[j],perm[from]); } } } int main(int argc,char * argv[]) { char s1[]="abcd"; CallAllPermutation(s1,0,3); return 0; }
相关文章推荐
- 驱动教程解码密码
- PowerDesigner教程系列
- 如何开启一个事务
- opencv 二值化图像 像素统计 countNonZero
- Struts2模型驱动核心机制详解
- lua-base64-MD5
- Meanshift,聚类算法
- sqlserver数据库还原语句
- 庆祝我的Hexo博客搭建成功-nianhua110.github.io
- LoadRunner压力测试--windows资源监控计数器
- GTxxxx系列------如何读取某个gpio的当前的状态
- 【设计模式之三工厂】
- 正则表达式
- 在 KitKat以上版本中使用Translucent将Navigation Bar透明化
- asm基础——计算机的原码和补码
- app后端设计--总目录 (转)
- AJAX
- Iconv作用以及安装问题解决
- PowerDesigner之CDM、PDM、SQL之间转换
- Mybatis学习——基本增删改查(CRUD)