jz5 #1913(2007/08/06 05:52 GMT) [ VB.net ] Rating0/0=0.00
mがnに近くなると効率悪くなりますが。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Public Sub DrawLots(ByVal n As Integer, ByVal m As Integer) If n < m OrElse n < 1 Then Exit Sub End If Dim list As New List(Of Integer) Dim r As New Random Do Dim v As Integer = r.Next(1, n + 1) If Not list.Contains(v) Then list.Add(v) If list.Count = m Then Exit Do End If End If Loop list.Sort() For Each i As Integer In list Console.WriteLine(i) Next End Sub
Rating0/0=0.00-0+
[ reply ]
jz5
#1913()
[
VB.net
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]