想问下这个求所有组合的递归具体该怎么实现呢,想了好久了,问了好多次都没人回答
1条回答 默认 最新
- 小公鸡卡哇伊呀~ 2021-10-23 22:02关注
第一步先求字符的集合,删除重复字母,再进行排序,这个容易。
第二步不怎么好解,这有详细说明和 c code,有method 1, method 2...Print all possible combinations of r elements in a given array of size n - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. https://www.geeksforgeeks.org/print-all-possible-combinations-of-r-elements-in-a-given-array-of-size-n/
code 里稍微修改一下,比如 int array 改成 char array
for (int i=1; i <= 3; i++)
printCombination(arr, n, i);
然后就可以打印出结果. a, b, c, ab, ....本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 腾讯云如何建立同一个项目中物模型之间的联系
- ¥30 VMware 云桌面水印如何添加
- ¥15 用ns3仿真出5G核心网网元
- ¥15 matlab答疑 关于海上风电的爬坡事件检测
- ¥88 python部署量化回测异常问题
- ¥30 酬劳2w元求合作写文章
- ¥15 在现有系统基础上增加功能
- ¥15 远程桌面文档内容复制粘贴,格式会变化
- ¥15 这种微信登录授权 谁可以做啊
- ¥15 请问我该如何添加自己的数据去运行蚁群算法代码