Dim a(13) As Integer
Print "猜牌术1:"
j = 1
For i = 1 To 13
n = 0
While n <i - 1
If j <13 Then j = j + 1 Else j = 1
If a(j) = 0 Then n = n + 1
Wend
a(j) = i
Next i
For i = 1 To 13
Print a(i)
Next i
End Sub
令黑桃渣败编搏备号为1~13,红桃编号为14~26,则魔术师手中的牌原始顺序如银颤是这样安排的:
1 19 10 2 25 16 3 11 22 4 20 12 5 17 26 6 13 24 7 18 14 8 21 23 9 15
Private Sub Command2_Click()
Dim a(26) As Integer
Print "猜牌2:"
j = 1
For i = 1 To 26
a(j) = i
n = 0
If i <26 Then
While n <3
If j <26 Then j = j + 1 Else j = 1
If a(j) = 0 Then n = n + 1
Wend
End If
Next i
For i = 1 To 26
Print a(i)
If i Mod 13 = 0 Then Print
Next i
End Sub
Sub xxx()Dim i As Integer, n As Integer, p As Integer, m As Integer
Dim arr(1 To 13) As Integer
Dim brr(1 To 54) As Boolean
arr(1) = 1
p = 0 '用来定位开始记牌的位置
For i = 1 To 13
n = 0
m = 1
Do While m < 55
If p + m > 54 Then p = 0: m = 1 '当54张牌数完,重新回到第一张牌
If brr(p + m) = False Then '判断这张牌是否是已经挑出来的牌,如果是已经挑出来的牌,则跳过
n = n + 1 'n用来数第几张牌
If n = i Then
arr(i) = p + m '定位每张黑桃i的位置
brr(p + m) = True '已经挑出来的牌,则标记为True
p = p + m '将定位变量p,定位到p+m
Exit Do '退出Do循环
End If
End If
m = m + 1
Loop
Next
Dim s As String
s = "牌号 - " & "位置" & 耐搜Chr(10)
For m = 1 To 13
s = s & " " & m 此亩庆& " - " & arr(m) & 森握Chr(10)
Next
MsgBox s
End Sub
答案是:
A 2 3 4 5 6 7 8 9 10 J Q K
1 3 6 10 15 21 28 36 45 2 17 31 46
顺过来就是:A,10,2,3,4,5,J,6,7,Q,8,9,K
搜了一下,C语言写出来的好像是1,8什么的……
楼主自己用笨方法数一数吧, 我数出来跟我得出来的结果貌似一样!!!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)