大家好,欢迎来到IT知识分享网。
private int[] arr = new int[] {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
private int num = 11;
private int[] result = null;
private int index = 0;
// Start is called before the first frame update
void Start () {
result = new int[num];
GetCombiNationMod (arr, result, 0, num);
}
/// <summary>
///
/// </summary>
/// <param name="_arr">原始数组</param>
/// <param name="_result">存储结果的数组</param>
/// <param name="_start">开始遍历的索引</param>
/// <param name="_count">提取几个元素</param>
private void GetCombiNationMod (int[] _arr, int[] _result, int _start, int _count) {
for (int i = _start; i < _arr.Length; i++) {
_result[_count - 1] = i;
if ((_count - 1) == 0) {
var v = "";
for (int j = _result.Length - 1; j >= 0; j--) {
v += _arr[_result[j]].ToString ();
}
index++;
print (index + " " + v);
} else {
GetCombiNationMod (_arr, _result, i + 1, _count - 1);
}
}
}
参考资料:https://blog.csdn.net/qq_33913037/article/details/72867772?utm_medium=distribute.pc_relevant_bbs_down.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_bbs_down.none-task-blog-baidujs-1.nonecase
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/11068.html