阅读896 返回首页    go 阿里云 go 技术社区[云栖]


C#递归求排列组合

如:根据123,可以写出:123,132,213,231,312,321种排列组合顺序。

using System; using System.Collections; class Program { static void Main(string[] args) { Permutate("12345", "", 0); } static void Permutate(string str, string result, int length) { if (str.Length == length) { Console.WriteLine(result); } for (int i = 0; i < str.Length; i++) { Permutate(str.Remove(i, 1), result + str[i], length); } } }

最后更新:2017-04-02 04:26:02

  上一篇:go 说说Yui2.0组件体系特点
  下一篇:go magento -- 1.4的不同之处零散记录一