作者rosemary (原po比较老)
看板Visual_Basic
标题Re: [.NET]乱数不重复
时间Thu Oct 6 14:29:48 2005
※ 引述《HeyScng ( )》之铭言:
: 这是我的想法
: 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
For i = 1 to 9
: j = Int(Rnd() * 9 + 1)
: temp = A(i) ////交换两张牌
: A(i) = A(j)
: A(j) = temp
: Next
: Button1.Text = A(1)
...(中省略)
: Button9.Text = A(9)
Dim btn() As Button = {Button1, Button2, Button3, Button4, _
Button5, Button6, Button7, Button8, Button9}
For i = 0 To 8
btn(i).Text = A(i + 1)
Next
: 基本上的想法是先设初值number 1~9 并随机交换这九个数字以达到乱数的目地
: 最後後传回A(1)~A(9)则为乱数 可是总跑不出来
因为回圈写错了 :)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 192.192.5.253
1F:推 HeyScng:卸卸你!! 218.170.114.20 10/06 23:08