题型:综合题 题类:常考题 难易度:普通
浙江省嘉兴市第一中学2020届高三上学期信息技术期中考试试卷
输入2350123456783,先将字符串拆成三段,分别是235,012345678,3要求每一段必须严格有序,如果无法实现连续升序,则单独作为一个拆分。
原字符串 | 235 | 012345678 | 3 | |||
连续升序字符数 | 3 | 9 | 1 | |||
密文 | 235 | 3 | 012345678 | 9 | 3 | 1 |
在文本框Text1中输入原文,单击“加密”按钮,可在文本框Text2中输出密文。
在文本框Text2中输入密文,单击“解密”按钮,可在文本框Text3中输出原文。
Private Sub Command1_Click() '加密过程
Dim a(1 To 100) As String
Dim s1, s2 As String: Dim tmp As Integer
tmp = 1: s1 = Text1.Text
For i = 1 To Len(s1)
a(i) = Mid(s1, i, 1)
Next i
s2 = a(1)
For i = 2 To Len(s1)
If ① Then
s2 = s2 + a(i): tmp = tmp + 1
Else
s2 = s2 + LTrim(Str(tmp)) 'LTrim()函数用以移除左边的符号位空字符
s2 = s2 + a(i)
②
End If
Next i
s2 = s2 + LTrim(Str(tmp)) : Text2.Text = s2
End Sub
Private Sub Command2_Click()'解密过程
Dim b(0 To 100) As String
Dim k As String, t As Integer, n As Integer
Dim s As String, s3 As String, j As Integer
s = Text2.Text: n = Len(s)
For i = 1 To n
b(i) = Mid(s, i, 1)
Next i
t = n - 1: k = Val(b(n))
Do While t > 0
If k <> 0 Then
For j = 1 To k
③
t = t - 1
Next j
k = Val(b(t))
t = t - 1
Else
k = 10
t = t - 1
End If
Loop
Text3.Text = s3
End Sub
① ② ③
list1=[“welcome”,“to”,“Python”,“World”] print(list1[2]) |
试题篮