博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
递归实现全排列
阅读量:7199 次
发布时间:2019-06-29

本文共 631 字,大约阅读时间需要 2 分钟。

#include 
#include
static void swap(char* pchar1, char* pchar2) { //交换数组的两个数 char tmp = *pchar1; *pchar1 = *pchar2; *pchar2 = tmp;}void permutation(char* pchar, int begin, int length) { int i; if(begin == length) {  //当只剩下一个元素时,打印数组 printf("%s\n", pchar); return; } for(i = begin; i <= length; i++) { swap(&pchar[begin], &pchar[i]); permutation(pchar, begin+1, length); swap(&pchar[begin], &pchar[i]); }}int main() { char arr[] = "abc"; permutation(arr, 0, strlen(arr)-1);}

 

转载于:https://www.cnblogs.com/13jhzeng/p/5294532.html

你可能感兴趣的文章
MySQL错误:The user specified as a definer (XXX@XXX) does not exist
查看>>
tomcat服务器重启后session可以继续使用
查看>>
SQL Server 全文索引介绍(转载)
查看>>
根据key删除Map集合中的key-value映射
查看>>
支持并发的httpclient(基于tcp连接池以及netty)
查看>>
Vuex的入门教程
查看>>
微服务架构实战
查看>>
语音信号处理之(三)矢量量化(Vector Quantization)
查看>>
hdu 4666 Hyperspace
查看>>
linux中shell变量$#,$@,$0,$1,$2的含义解释
查看>>
多态时最好将基类的析构函数设为virtual、 C++中两个类相互包含引用问题 (转载)...
查看>>
JS动态生成的元素,其对应的方法不响应(比如单击事件,鼠标移动事件等)...
查看>>
iOS - Swift PList 数据存储
查看>>
[转载]Windows 2003 R2 SP2 VOL 企业版(简体中文)
查看>>
java web 分页实现
查看>>
谈谈区块链的理解 -- 读《区块链:技术驱动金融》
查看>>
模板类声明和定义 (转)
查看>>
RSync 远程同步工具的使用
查看>>
C++访问mysql数据库
查看>>
字符测试与映射函数 ctype.h
查看>>