作者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