让所有的组合在数组 [英] Getting all the combinations in an array
问题描述
说我有以下数组:
var arr = new[] { "A", "B", "C" };
我怎么能生产出只包含两个字符,并没有两个相同的(例如 AB可能的组合
将是一样的 BA
)。例如,使用上述阵列它会产生
How can I produce all the possible combinations that contain only two characters and no two the same (e.g. AB
would be the same as BA
). For example, using the above array it would produce:
AB
AC
BC
请注意,本实施例中已经简化。阵列和所需要的字符串的长度也会更大。
Please note that this example has been simplified. The array and the length of the string required will be greater.
我真的AP preciate如果有人可以帮助。
I'd really appreciate if someone could help.
推荐答案
这应该给你一个起点:
<一href=\"http://www.interact-sw.co.uk/iangblog/2004/09/16/permuterate\">http://www.interact-sw.co.uk/iangblog/2004/09/16/permuterate
<一href=\"http://www.$c$cproject.com/KB/recipes/Combinatorics.aspx\">http://www.$c$cproject.com/KB/recipes/Combinatorics.aspx
这篇关于让所有的组合在数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!