试题

试题 试卷

logo

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

浙江省山水联盟2020届高三下学期信息技术4月返校考试试卷

输入一段长度为n的英文字母,对其进行某种加密方法,描述如下:

⑴将原文转换为若干行m列(m为奇数)的矩阵,最后一行若不足m个数据则以“#”填充。

⑵将矩阵中的数据,从末行末列数据开始以回路的方式提取字符。按顺序生成加密字符。例如对字符“helloworld”,m=3的加密过程如下图,其加密结果为“#lwleor#dolh”

 

程序窗口界面如图:

请回答下列问题:

(1)、字符串“helloworld”经过加密后密文为“dollrleowh”,则加密矩阵列数m为
(2)、上述加密算法对应解密的VB程序代码如下,请在划线处填入合适的代码。

Private Sub command1_click()

    Dim a As String, n As Integer, yw As String

    Dim i As Integer, j As Integer

    Dim index As Integer, k As Integer, x As Integer

    s = Text1.Text '文本框text1中为待解密的字符串

    m = Val(Text2.Text)

    n = Len(s)

    yw = ""

    k = 0

    x = n / m

    For i = 1 To

        index = n - i + 1

        yw = yw + Mid(s, index, 1)

        For j = 2 To m

            IfThen

                index = index - 2 * (x - i) - 1

            Else

                index = index - 2 * (i - 1) - 1

            End If

            If Mid(s, index, 1) = "#" Then

              yw = yw + Mid(s, index, 1)

        Next j

    Next i

    Label1.Caption = Mid(yw, 1, Len(yw) - k)

End Sub

举一反三
返回首页

试题篮