作者yauhh (姚呵呵)
看板Visual_Basic
标题Re: [ASP ] 想写个像乐透的程式但是遇到了瓶颈
时间Tue Apr 1 01:38:51 2008
前面讲的取球法若觉得不好写,
可以用洗牌法简单做出来.
dim ar(41) as integer, i as integer
for i = 0 to 41
ar(i) = i+1
next i
randomize()
for i = 1 to 400
dim x as integer, y as integer
dim temp as integer
x = int(rnd() * 42)
y = iny(rnd() * 42)
temp = ar(x)
ar(x) = ar(y)
ar(y) = temp
next i
for i = 0 to 6
console.write(" {0} ", ar(i))
next i
单组一定数字不重覆,
二组以上要多写点程式检查组与组的重覆.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.160.212.10
1F:推 xtimer:抓个小错误 第10行 应该是Int 04/01 03:39
2F:→ yauhh:手误 04/01 13:25
3F:推 xtimer:呵呵~~看懂了 谢谢分享 04/02 07:12