撲克牌發牌: (1) 首先將 52 張牌發成 4 份玩橋牌 (2) 再以橋牌的方式排列四組牌 (3) 花色由黑桃 -> 紅心 -> 磚塊 -> 梅花 (4) 每一個花色都由小至大排列。
2006-06-02 20:01:52 · 1 個解答 · 發問者 smoker 5 in 遊戲與休閒活動 ➔ 紙牌遊戲
'表單置1CommandButtonPrivate Sub Command1_Click() Dim A(3, 12) As Integer, B(51) As Boolean, I%, J%, N%, T% Cls '隨機發牌 Randomize For I = 0 To 12 For J = 0 To 3 Do N = Int(Rnd * 52) Loop Until B(N) = False B(N) = True A(J, I) = N Next Next '排序 For N = 0 To 3 For I = 0 To 12 For J = I To 12 If A(N, I) > A(N, J) Then T = A(N, I): A(N, I) = A(N, J): A(N, J) = T End If Next Next Next '輸出 For I = 0 To 3 Print "第"; I + 1; "家" For J = 0 To 12 Print SWAP(A(I, J)); Next Print Tab(2) NextEnd SubFunction SWAP(ByVal N As Integer) As String '換算花色 Select Case N \ 13 Case 0: SWAP = "黑桃)" Case 1: SWAP = "紅心)" Case 2: SWAP = "磚塊)" Case 3: SWAP = "梅花)" End Select SWAP = "(" & N Mod 13 + 1 & SWAPEnd Function
2006-06-05 08:39:10 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋