试题

试题 试卷

logo

题型:综合题 题类:常考题 难易度:困难

浙江省名校协作体2019届高三上学期信息技术9月联考试卷

【加试题】某密码的破译步骤如下:

⑴找出文章(以“.”结束)中所有用英文表示的数字(均为小写,数字范围1≤n≤20),单词与数字对应如下:

⑵将这些数字平方后除以100取余,得到两位数如00,04,21,96。

⑶把这些两位数按升序排成一行,组成一个最小的新数,如果新数开头为0,就去除。

⑷步骤(3)找出的最小数即为密码。

小明按照上述方法,设计了一个解密的VB程序,功能如下:单击“解密”按钮Command1,程序依次将文本框Text1中以空格分隔的每个英文单词取出,若单词属于数字单词,则按解密步骤进行处理,最后在文本框Text2中输出解密结果。

程序运行效果如图所示,请回答下列问题:

(1)、若文章内容为“tom bought two apples and five oranges, which cost ten dollars altogether.”,则破译后的密码应为
(2)、请在划线处填入合适的代码。

Dim a(1 To 20) As String

Private Sub Form_Load()

    a(1) = "one": a(2) = "two" 

    ‘……将所有数字单词按顺序存入数组a中,代码略

End Sub

Private Sub Command1_Click()

    Dim s As String, tmp As String

    Dim c as Integer, i As Integer, j As Integer, k As Integer, t As String, ch As As String, code As Long

    Dim b(1 To 100) As String   ‘b数组存放数字单词处理后得到的两位数

    s = Text1.Text

    c = 0: i = 1: flag = True:t = ""

    Do While i <= Len(s)

        ch = Mid(s, i, 1)

        If ch >= "a" And ch <= "z" Then

            t = t + ch

            flag = False

        ElseIf flag = False Then

            For j = 1 To 20

                If t = a(j) Then

                    c = c + 1

                    b(c) =

                End If

            Next j

            t = ""

            flag = True

        End If

        i = i + 1

    Loop

    ’将b数组中的两位数按数值大小进行升序排序,代码略

    For i = 1 To c

        t = Val(b(i))

   

    Next i

    Text2.Text = Str(code)

End Sub

Function decode(num As Integer) As String

  Dim mo As Integer

  mo = num * num Mod 100

  If mo = 0 Then

    decode = "00"

  ElseIf    Then

    decode = "0" + Trim(Str(mo))

  Else

    decode = Trim(Str(mo))  'Trim为去除字符串两端空格的函数

  End If

End Function

举一反三
返回首页

试题篮