作者goaremdy (我要当气质型男)
看板NTUBSE-B-98
标题Re: [请问] 计程作业...
时间Mon Jun 7 10:20:47 2010
有情有义生工人
7.13
In the card shuffling and dealing program of Fig 7.24, we intentionally
used an inefficient shuffling algorithm that introduced the possibility of
indefinte postponement. In this problem, you will create a high-performance
shuffling algorithm that avoids indefinite postponement.
Modify the program of Fig 7.24 as follows. Begin by initializing the deck
array as shown in Fig 7.29. Modify the shuffle function to loop row-by-row and
column-by-column through the array, touching every element once. Each element
should be swapped with a ramdomly selected element of the array.
Unshuffled deck array
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
1 14 15 16 17 18 19 20 21 22 23 24 25 26
2 27 28 29 30 31 32 33 34 35 36 37 38 39
3 40 41 42 43 44 45 46 47 48 49 50 51 52
Fig 7.24 是洗牌发牌程式,篇幅有点大,有需要我再贴。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.242.75
1F:推 chinting :果然有情有义!!!感谢~~ 06/07 12:24
2F:→ DKer :ceiba刚刚也有了 噗 06/07 13:19
3F:推 Hachi329 : 噗 06/07 17:38
4F:推 chinting : 噗~ 06/07 19:02