作者HeyScng ( )
看板Visual_Basic
標題[.NET]亂數不重複
時間Thu Oct 6 12:39:46 2005
這是我的想法
Dim A() As Integer = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
Dim temp As Integer
Dim i,j As Integer
For i = 1 To i = 9
j = Int(Rnd() * 9 + 1)
temp = A(i) ////交換兩張牌
A(i) = A(j)
A(j) = temp
Next
Button1.Text = A(1)
Button2.Text = A(2)
Button3.Text = A(3)
Button4.Text = A(4)
Button5.Text = A(5)
Button6.Text = A(6)
Button7.Text = A(7)
Button8.Text = A(8)
Button9.Text = A(9)
基本上的想法是先設初值number 1~9 並隨機交換這九個數字以達到亂數的目地
最後後傳回A(1)~A(9)則為亂數 可是總跑不出來
誰可以給我點意見嗎??謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.134.140.40