大家鉴定,这段代码能否实现双色球随机选号??
Imports System.CollectionsPublic Class clsSelect
Public Function myRedBallSelect(ByVal intPra As Integer) As Hashtable
Dim intHasKey As Integer = 0
'hashTable Create
Dim hasTable As New Hashtable()
Dim hasRedBall As New Hashtable()
Dim hasTemp As New Hashtable()
'Red balls save
For i As Integer = 1 To intPra
hasTable.Add(i, i)
Next
intHasKey = CInt(intPra * Rnd()) + 1
'Red ball1 追加
hasRedBall.Add(1, hasTable(intHasKey))
'Red ball2 追加
hasTemp = hasTable
For i As Integer = intHasKey To intPra - 1
hasTemp(i) = hasTable(i + 1)
Next
intHasKey = CInt((intPra - 1) * Rnd()) + 1
'Red ball2 追加
hasRedBall.Add(2, hasTemp(intHasKey))
'Del
hasTemp.Remove(intPra)
'Red ball3 追加
hasTable = hasTemp
For i As Integer = intHasKey To intPra - 2
hasTemp(i) = hasTable(i + 1)
Next
intHasKey = CInt((intPra - 2) * Rnd()) + 1
'Red ball3 追加
hasRedBall.Add(3, hasTemp(intHasKey))
'Del
hasTemp.Remove(intPra - 1)
'Red ball4 追加
hasTable = hasTemp
For i As Integer = intHasKey To intPra - 3
hasTemp(i) = hasTable(i + 1)
Next
intHasKey = CInt((intPra - 3) * Rnd()) + 1
'Red ball4 追加
hasRedBall.Add(4, hasTemp(intHasKey))
'Del
hasTemp.Remove(intPra - 2)
'Red ball5 追加
hasTable = hasTemp
For i As Integer = intHasKey To intPra - 4
hasTemp(i) = hasTable(i + 1)
Next
intHasKey = CInt((intPra - 4) * Rnd()) + 1
'Red ball5 追加
hasRedBall.Add(5, hasTemp(intHasKey))
'Del
hasTemp.Remove(intPra - 3)
'Red ball6 追加
hasTable = hasTemp
For i As Integer = intHasKey To intPra - 5
hasTemp(i) = hasTable(i + 1)
Next
intHasKey = CInt((intPra - 5) * Rnd()) + 1
'Red ball6 追加
hasRedBall.Add(6, hasTemp(intHasKey))
Return hasRedBall
End Function
Public Function myBlueBallSelect(ByVal intPra As Integer) As String
Dim strResult As String = Nothing
strResult = (CInt(Int(intPra * Rnd() + 1))).ToString
Return strResult
End Function
End Class --------------------编程问答-------------------- 实例时最好给个种子它,如
Dim r As New Random(Now.Millisecond)
补充:.NET技术 , VB.NET