0
Q
從列表中隨機挑選
A
回答
0
隨機挑選一些uniq的數字
是否這樣?
Dim firstlist() = {1, 2, 3, 6, 7, 9, 12, 16}
Dim seclist As New Collection
Dim rnd As New Random
Debug.WriteLine("__")
Dim i As Integer = 1
While i <= 3
Dim j As Integer = CInt(rnd.Next(0, firstlist.Length - 1))
If Not seclist.Contains(j) Then
seclist.Add(firstlist(j), j)
Debug.WriteLine(CStr(firstlist(j)))
i += 1
End If
End While
'seclist now contains 3 values (data) and the indices (key)
0
Dim firstlist = {1, 2, 3, 6, 7, 9, 12, 16}
dim secondlist as new list(of integer)
dim rand as new random()
while not secondlist.count = 3
secondlist.add(firstlist(rand.next(firstlist.count-1)))
end while
相關問題
- 1. 隨機在python列表中挑選
- 2. 從4個表中隨機挑選
- 3. 從列表中隨機挑選列表內容
- 4. 球拍 - 從列表中挑選一個隨機元素
- 5. 從ini文件中讀取值列表隨機挑選
- 6. 如何隨機從類列表中挑選
- 7. 從數組列表中挑選隨機顏色
- 8. 如何挑選隨機陣列中的
- 9. 挑選隨機值
- 10. ArrayList隨機挑選
- 11. 從string.xml中挑選隨機字符串
- 12. 從數組中挑選隨機數
- 13. 從數組中挑選隨機顏色
- 14. 從數組中挑選隨機NSNumber?
- 15. Python - 從3x3 NP陣列中挑選隨機的列或行
- 16. 從字典和隨機項目列表中挑選隨機列表並將其顯示在textBlock中?
- 17. 隨機選擇從列表
- 18. 從sql mtouch測驗挑選隨機行
- 19. 挑選隨機線從標準輸出
- 20. android挑選隨機圖片?
- 21. Math.Random()挑選隨機數組
- 22. 挑選隨機名稱
- 23. 從陣列中挑選一個隨機數組元素
- 24. 從netLogo中的字符串列表/數組中挑選一個隨機元素
- 25. 從下拉列表中隨機選擇?
- 26. 從Java列表中隨機選擇[]
- 27. 從列表中選擇隨機段落
- 28. Python不從列表中隨機選擇
- 29. 從數組列表中隨機選擇
- 30. 從列表中選擇隨機短語
的可能重複[C#:是使用隨機和排序依據良好的洗牌算法(http://stackoverflow.com/questions/1287567/c-is-using-random-and-orderby -a-good-shuffle-algorithm) –
(我所鏈接的問題實際上並不是最接近的重複*問題*,但它有最相關的答案* IMO :) –
@Jon:我猜對了誰那個答案的作者是。 :) – John