试题

试题 试卷

logo

题型:综合题 题类:模拟题 难易度:困难

浙江省杭州市五县七校2017届高三上学期期中联考信息技术试题

曲哲同学设计了一个英文字符串的加密算法,其加密的方法如下:

从被加密字符串中获取单个字符,然后得到其ascii码的8位二进制编码。

将字符的二进制编码反向,得到其逆序二进制码。

将逆序二进制码的每4位转换为相应的十六进制编码,即得到单个字符加密后的字符串。

以此类推,直到所有字符加密完成,得到加密字符串。

具体程序界面如下图,在text1中输入字符串,点击“加密”按钮command1后,在text2中显示加密后的字符串。

(1)、已知字符a的ascii码为97,则字符串idear加密后的字符串为
(2)、阅读整段程序,程序中①画线处应填入

程序中②画线处应填入

Private Sub Command1_Click()

Dim s As String, ch As String

Dim result As String, chA As String, chB As String

Dim i As Integer, j As Integer

Dim n As Integer, m As Integer

s = Text1.Text

n = Len(s)

result = "": c = "0123456789ABCDEF"

For i = 1 To n

    ch =           ①             

    ch = niXu(ch)

    m = 0

    For j = 1 To 4  ' 获取二进制码前4位的值

                   ②              

    Next

    chA = Mid(c, m + 1, 1)

    m = 0

    For j = 5 To Len(ch)

        m = m * 2 + Val(Mid(ch, j, 1))

    Next

    chB = Mid(c, m + 1, 1)

    result = result + chA + chB

Next

Text2.Text = result

End Sub

' 得到单个字符ch的8位二进制编码

Function D2B(ByVal ch As String) As String

    Dim s As String

    Dim data As Integer, i As Integer

    data = Asc(ch):s = ""

    Do While data > 0

        s =Str(data Mod 2) + s

        data = data \ 2

    Loop

    If Len(s) < 8 Then

        For i = 1 To 8 - Len(s)

            s = "0" + s

        Next

        D2B = s

    Else

        D2B = s

    End If

End Function

' 返回字符串s的逆序

Function niXu(ByVal s As String) As String

    Dim i As Integer:Dim r As String

    r = ""

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

        r = r + Mid(s, i, 1)

    Next

    niXu = r

End Function

返回首页

试题篮