标题:【求助】看看魔术师这题怎么解。
取消只看楼主
liuyun007
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2021-3-23
 问题点数:0 回复次数:0 
【求助】看看魔术师这题怎么解。
过年期间,已经完成了所有作业的小吴同学和朋友们玩起了卡牌魔术:有13张扑克牌(A 2 3 4 5 6 7 8 9 10 J Q K),预先排好,牌面朝下,从最上面开始,将第一张牌翻过来看正好是A;继续数手里的余牌,第二次数1,2将第一张牌放到这叠牌的下面,将第二张翻开,正好是黑桃2,也把它放在桌上;第三次数1,2,3,前面两张牌放到这叠牌的下面,取出第三张,正好是黑桃3,这样依次将13张牌翻出,正好是(A 2 3 4 5 6 7 8 9 10 J Q K),求:牌的原始顺序应该怎样排呢?为解决这个问题,小吴编写了一个VB程序运行如下:
为实现上述功能,请在划线处填入合适的代码:
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer
Dim t As Integer, temp As Integer
Dim a(1 To 13) As Integer
Dim jg As String
Const kp = "JQK"
a(13) = 1
For i = 12 To 1 Step -1      
    _____①____
    For j = i + 1 To 13                 
        a(j) = a(j) + 1                 
    Next j
    For j = 1 To i - 1
        _____②_____
        For k = 13 To i + 1 Step -1
            t = k + 1
            If t > 13 Then t = i
            a(t) = a(k)
        Next k
        _______③_____
    Next j
Next i
List1.AddItem "牌堆的原始顺序为:"
For i = 1 To 13
    If a(i) = 1 Then
        jg = "A"
    ElseIf a(i) > 10 Then
        jg = _____④_________
    Else
        jg = CStr(a(i))
    End If
    List1.AddItem jg
Next i
End Sub

搜索更多相关主题的帖子: Dim Next For If Integer 
2021-03-23 15:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-505224-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.185483 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved