试题

试题 试卷

logo

题型:综合题 题类:真题 难易度:困难

浙江省普通高校招生选考科目信息技术试卷(2019.4)

小王设计“模拟撤销”程序,需要用一个“历史记录”,“历史记录”是在对字符串s进行插入或删除时,将每步操作信息依次存储得到的,操作信息由操作符(“+”表示插入,“-”表示删除)、操作位置和操作字符串(只包含英文字母)构成,例如,“+23abc”表示在字符串s第23个位插入了“abc”,“模拟撤销”过程按照“历史记录”的逆序进行,将字符串s的内容恢复到初始状态。对字符串“Book”的操作与撤销过程,如a所示。

图a

图b

小王编写的“模拟撤销”VB程序如下,文本框 Text1中的内容是撤销前字符串,文本概Text2中的内容是历史记录,单击“撤销”按钮Command1后,在标签Label1中显示撤销过程,程序运行界面如图b所示。

(1)、实观上述功能的VB程序如下,在程序中出现的对象没有Caption属性的是 。(选填,填字码:A .Label1  /B .Command1  /C .Text1和Text2)
(2)、请在划线处填入合适代码。

Private Sub Command1_Click()

    Dim s As String, t As String, ch As String

    Dim c As String, num As String, ss As String

    Dim n As Integer, i As Integer

    s = Text1.Text: t = Text2.Text

    c = "": num = "": ss = s

    For i = Len(t) To 1 Step -1

            ①     

        If ch >= "a" And ch <= "z" Or ch >= "A" And ch = "Z" Then

            c = ch + c

        ElseIf ch >= "0" And ch <= "9" Then

            num = ch + num

        Else

            n = Val(num)

            If ch = "-" Then

                s = Mid(s, 1, n - 1) +    ②  

            Else

                s = Mid(s, 1, n - 1) + Mid(s, n + Len(c), Len(s) - n - Len(c) + 1)

            End If

            ss = ss + "→" + s

            c = "": num = ""

        End If

    Next i

    Label1.Caption = ss

End Sub

 ②

(3)、运行该程序,若文本框Text1中的内容是"April",文本框Text2中的内容是“-3p+3ri-6e”,单击撤销按钮,For循环语句执行完成后,字符串s的值是
举一反三
返回首页

试题篮