Re: [ASP ] 想寫個像樂透的程式但是遇到了瓶頸
前面講的取球法若覺得不好寫,
可以用洗牌法簡單做出來.
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
推
04/01 03:39, , 1F
04/01 03:39, 1F
→
04/01 13:25, , 2F
04/01 13:25, 2F
推
04/02 07:12, , 3F
04/02 07:12, 3F
討論串 (同標題文章)
完整討論串 (本文為第 5 之 5 篇):