1
A
回答
0
如果編程語言是不關心的,至少有兩種可能產生組合的列表。
首先枚舉整型的位模式,可以按如下方式完成。
1. Let n be the number of boolean variables.
2. Enumerate each number from 0 to 2^n-1.
3. For each of these numbers, say e, generate an assignment of the
boolean variables where the i-th variable is assigned true
if and only if the i-th bit of e is set.
4. Save each of these assignments.
其次通過迭代生成可以完成的分配如下。
1. Initialize a list l with one entry; the single entry
represents a potential assignment of the variables.
2. While there are entries in the list in which there is an unassigned
variable, execute the following steps, where c is a list of candidate assignments.
3. For each entry in l which has an unassigned variable, say e, generate two entries in c,
namely one where the unassigned variable is set to true and one in
which it is set to false. Remove e from l.
4. Merge the candidate list c into l.
相關問題
- 1. 獲得各種可能的組合列
- 2. 生成所有可能的真/假組合
- 3. JumpList和ClickOnce - 這種組合可能嗎?
- 4. MySQL的 - 插入值的各種可能組合成兩列
- 5. 以各種可能的組合調用函數
- 6. SQL各種組合由
- 7. 每種可能的組合
- 8. 真假合金
- 9. 如何迭代此代碼的所有可能組合?
- 10. 迭代器只能迭代一次嗎?
- 11. 正則表達式與各種組合
- 12. 獲取多種可能的組合Python
- 13. 擁有各種可能的佈局
- 14. 集合中的迭代,不理解這種迭代的方式
- 15. 是這種方式保存js高效的真/假選項嗎?
- 16. 各種類型的集合
- 17. WCF服務可以組成各種界面嗎?
- 18. 整潔的代碼轉換布爾[] - >「假,真,真,假」
- 19. 迭代二維布爾數組並根據真/假返回一個遞增值
- 20. 迭代器可以更改它正在迭代的集合嗎? Java
- 21. 迭代地組合鏈表
- 22. 迭代後合併組
- 23. 在DataGridView列代替真/假
- 24. 與各種列表合併
- 25. C#能否像C++迭代器那樣區分各種枚舉類型?
- 26. 測試變種,可能是陣列/空數組/假
- 27. flowdocumentscrollviewer段可見真假
- 28. 使用範圍列表:根通過各種數值迭代
- 29. 迭代bash數組,動態替換數組名稱,這可能嗎?
- 30. 我可以以這種方式返回迭代器嗎?
你想用特定的編程語言實現某些東西嗎?有很多方法可以生成該查找,這取決於上下文。 – Codor
@Codor我真的不在乎語言,我只想看看它背後的邏輯。 – JorensM
只需從0到15進行計數,並使用按位運算符來提取0到3位。 –