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