Stats

Popular Posts

Followers

PTT:Excel大樂透49取6亂數列出1000筆組合

養花種魚數月亮賞星星 於 2008年9月20日星期六 下午9:13 發表
Sub lotto()
Dim Fn As Object
Set Fn = Application.WorksheetFunction
For k = 1 To 1000
For i = 1 To 6
Cells(k, i) = Fn.RoundUp(Rnd * 49, 0)
For j = 1 To i - 1
If Cells(k, i) = Cells(k, j) Then i = i - 1
Next
Next
Next
End Sub

如果你有Mathematica的話,那就方便多了

<<>
Table[RandomKSubset[Range[49], 6], {i, 1, 1000}]

這樣就ok~~ Tags: ,

讀者回應 ( 0 意見 )

發佈留言

Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.

如果這篇文章對你有幫助,那請留個訊息給我~