請問有沒有人寫簡單的亂數產生樂透彩號碼的語法 |
尚未結案
|
kennan8176
一般會員 發表:8 回覆:9 積分:3 註冊:2005-04-11 發送簡訊給我 |
|
kartan_01
一般會員 發表:42 回覆:60 積分:20 註冊:2004-12-08 發送簡訊給我 |
本來應該要用多執行緒來做,現在只做出選出7個不重複的數字
以及亂數的分配實在不夠亂
A1:=0; A2:=0; A3:=0; A4:=0; A5:=0; A6:=0; A7:=0; //第1個數 m:=system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A1:=rem1.Next(1,49); //第2個數 m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A2:=rem1.Next(1,49); WHILE(A2 = A1) DO begin m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A2:=rem1.Next(1,49); end; //第3個數 m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A3:=rem1.Next(1,49); WHILE(A3 = A1) OR (A3 = A2) DO begin m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A3:=rem1.Next(1,49); end; //第4個數 m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A4:=rem1.Next(1,49); WHILE(A4 = A1) OR (A4 = A2) OR (A4 = A3) DO begin m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A4:=rem1.Next(1,49); end; //第5個數 m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A5:=rem1.Next(1,49); WHILE(A5 = A1) OR (A5 = A2) OR (A5 = A3) OR (A5 = A4) DO begin m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A5:=rem1.Next(1,49); end; //第6個數 m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A6:=rem1.Next(1,49); WHILE(A6 = A1) OR (A6 = A2) OR (A6 = A3) OR (A6 = A4) OR (A6 = A5) DO begin m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A6:=rem1.Next(1,49); end; //第7個數(特別號) m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A7:=rem1.Next(1,49); WHILE(A7 = A1) OR (A7 = A2) OR (A7 = A3) OR (A7 = A4) OR (A7 = A5) OR (A7 = A6) DO begin m:=m system.DateTime.Now.Ticks; rem1:=system.Random.Create(m); A7:=rem1.Next(1,49); end; |
shieh2700
高階會員 發表:0 回覆:127 積分:100 註冊:2002-06-13 發送簡訊給我 |
Randomize() Dim ns(49) As Int16 Dim i As Int16 Dim r As Random = New Random Dim n As Int16 Dim m As Int16 For i = 1 To 49 ns(i) = i Next For i = 1 To 49 m = r.Next(1, 49) n = ns(i) ns(i) = ns(m) ns(m) = n Next Dim s As String For i = 1 To 7 s = s ns(i).ToString() " " Next MsgBox(s) |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |