递归 全排列
2016-02-01 15:36
351 查看
void swapChar(char str[], int i, int j) { int t = str[j]; str[j] = str[i]; str[i] = t; } void showString(char str[], int len) { if (len == 0) { cout << str-4 << endl; return; } for (int i = 0; i < len; i++) { swapChar(str, 0, i); showString(str + 1, len - 1); swapChar(str, 0, i); } } int main() { /*int a[] = { 1, 2, 7, 4, 6, 6, 7, 8, 10, 4 }; for (int i = 0; i < 10; i++) { cout << random_select(a, 0, 9, i+1) << endl; }*/ char str[] = "abcd"; showString(str, 4); return 0; }
相关文章推荐
- Linux学习笔记之<让进程在后台可靠运行的几种方法>
- nmap -- write a nmap script
- myBatis抛出异常Result Maps collection already contains value ...
- Liferay开发实战(1):入门
- linux screen 命令详解
- elipes遇到 source not found解决方案
- 基于vitamio5.0的android播放器
- maven学习(下)利用Profile构建不同环境的部署包
- php 自带过滤和转义函数
- ruby遍历文件夹下所有文件,输出文件名(migrate报错处理)
- Android中RelativeLayout各个属性的含义
- PHP利用memcache缓存技术提高响应速度
- Maven Web项目部署到Tomcat下
- jquery鼠标悬停导航下划线滑出效果
- Button的xml编写
- HTTP中cache-control的应用及说明
- 记录一次安装Loadrunner11遇到的各种问题,如PUTTY.GID找不到
- C#异常处理中try和catch语句及finally语句的用法示例
- RAID详解
- hdoj--3635--Dragon Balls(并查集记录深度)