C#数组项组合 [英] C# array items combinations

查看:193
本文介绍了C#数组项组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,程序员!



我遇到以下问题 - 我有二维数组2x3,名为 arr ,包含来自的字母 a f ,如下图所示:



 字符串 [,] arr =  new  字符串 [ 2  3 ] 
{
{ a < span class =code-string> b, c},
{ d e f}
};





我的目的是结合第一个c的所有项目olumn(a,d)包含第二列(b,e)中的所有项目以及第三列(c,f)中的所有项目。像这样:



 abc 
abf

aec
aef

dbc
dbf

dec
def





是否有任何公式可以提供我想要的解决方案可能?在编程组合学方面我很困惑。提前感谢您提供的任何帮助! :)

解决方案

检查这个





http://bytes.com/topic/c-sharp/answers/574570-cross-product-arrays [ ^ ]

Hello, programmers!

I'm experiencing the following problem - I have 2D array 2x3 named arr, containing the letters from a to f as shown below:

String[,] arr = new String[2, 3]
{
    { "a", "b", "c" },
    { "d", "e", "f" }
};



My purpose is to combine all the items from the first column (a, d) with all the items from the second column (b, e) with all the items from the third column (c, f). Like this:

a b c
a b f

a e c
a e f

d b c
d b f

d e c
d e f



Is there any formula that makes my desired solution possible? I'm stuck when it comes to programming combinatorics. Thanks in advance for any help provided! :)

解决方案

check this


http://bytes.com/topic/c-sharp/answers/574570-cross-product-arrays[^]


这篇关于C#数组项组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆