题型:综合题 题类:常考题 难易度:困难
浙江省嘉兴市第一中学2017-2018学年高二下学期信息技术期中考试试卷
Private Sub Command1_Click()
Dim msg As String, c As String, tmp As String, s As String, flag As Boolean msg = Text1.Text
msg = msg + "/" '标记字符串结束符
tmp = "" s = ""
flag = True
For i = 1 To Len(msg)
c = Mid(msg, i, 1)
If ① Then flag = False
tmp = tmp + c
ElseIf flag = False Then s = s + tmp + ","
tmp = ""
②
End If
Next i
Text2.Text = s
End Sub
⑴以字节为单位进行加密处理;
⑵将1个字节的8位二进制数分割成前4位与后4位两个二进制数;
⑶分别将上述两个4位二进制数转换为十进制数;
⑷将每个十进制数转换为1个加密字符,对应的“密码表”如下:
值(十进制) | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
加密字符 | I | l | i | k | e | C | H | N | P | 0 | s | t | c | a | r | d |
小明按照上述方法,设计了一个字符串(仅包含ASCII字符)加密的VB程序,功能如下:单击“加密”按钮Commandl,程序依次将文本框Textl中每个字符的ASCII码值作为1个字节转换为两个加密字符,连接这些加密字符,最后在文本框Text2中输出加密结果。下表显示了字符串中一个字符的加密过程:
程序运行效果如图所示。
实现上述功能的VB程序如下:
试题篮