English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

電腦分牌
利用亂數分牌,將52張撲克牌平均分給四個人,並輸出每人分得13張牌之「花色」與「點數」,如「黑桃8」、「梅花10」、「紅磚13」、「紅桃1」。

2006-12-31 09:08:51 · 1 個解答 · 發問者 小惠 1 in 電腦與網際網路 程式設計

1 個解答

你的螢幕上要有text1(0) ~ text1(3) 文字框 及 Comand1 按鈕
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, m As Integer, n As Integer
Dim a(52) As Integer
Dim buf(4) As String
buf(0) = "黑桃": buf(1) = "紅桃": buf(2) = "紅磚": buf(3) = "梅花"
Randomize
For i = 1 To 52
a(i) = 0
Next i
k = 0
For i = 1 To 52
Do
j = (Int(Rnd() * 52) + 1)
Loop While a(j) = 1
a(j) = 1
m = (j - 1) \ 13
n = (j - 1) Mod 13 + 1
Text4(k).Text = Text4(k).Text & buf(m) & n & ", "
If (i Mod 13 = 0) Then k = k + 1
Next i
End Sub
如果有問題, 請來函討論. 不然, 我可能會錯失你再補充的疑點.

2007-01-01 01:47:54 · answer #1 · answered by JJ 7 · 0 0

fedest.com, questions and answers