0和1的阵列组合 [英] Array combinations of 0s and 1s
问题描述
什么是好的算法,以填补0和1的组合阵列。 例如,如果我有三列的组合是: (1 1 1) (0 1 1) (1 0 1) (0 0 1) (1 1 0) (0 1 0) (1 0 0) (0 0 0) 它使共8行(我希望我就在这里)。 因此,如何确定行事先所需要的数量(取决于列N个),然后如何填写该数组了编程?任何编程语言是好的(我标记C和因为熟悉LISP),这是所需要的算法。谢谢
What is a good algorithm to fill an array with 0s and 1s combinations. For example if I have three columns the combinations would be: (1 1 1) (0 1 1) (1 0 1) (0 0 1) (1 1 0) (0 1 0) (1 0 0) (0 0 0) It makes a total of 8 rows (I hope I'm right here). So how to determine the needed number of rows in advance (depending on the N number of columns) and then how to fill the array out programatically? Any programming language is fine (I tagged C and lisp because of familiarity) it's the algorithm that is needed. Thanks
推荐答案
在基地从0数高达2
0 = 000
1 = 001
2 = 010
...
7 = 111
这篇关于0和1的阵列组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!