s = "abba"
n = Len(s) 's 是待判断的字符串
i = n \ 2: j = i + 1 + n Mod 2
Do While i > 0
Loop
If i = 0 Then Text1.Text= "对称" Else Text1.Text= "不对称"
方框中的代码由以下三部分组成:
①j = j + 1: i = i - 1
②If c1 <> c2 Then Exit Do
③c1 = Mid(s, i, 1): c2 = Mid(s, j, 1)
下列选项中,代码顺序正确的是( )
Key = Val(Text1.Text):s = 0: i = 1: j = 7
Do While i <= j
m = (i + j) \ 2
s = s + m
If a(m) > Key Then j = m - 1 Else i = m + 1
Loop
Text2.Text = Str(s)
数组元素a(1)到a(7)的值依次为“12,15,18,20,20,20,29”,在文本框Text1中输入待查数,执行该程序段后,则文本框 Text2 中显示的内容不可能的是( )
s = Text1.Text: k = 1: maxlen = 1
For i = 2 To Len(s)
If Mid(s, i - 1, 1) < Mid(s, i, 1) Then
k = k + 1
If k > maxlen Then maxlen = k
Else
k = 1
End If
Next i
Label1.Caption = Str(maxlen)
在文本框Text1 中输入字符串“B3b8defhADot”,执行该程序段后,则标签Label1 中显示的内容为( )
Const n = 10
Dim a(1 To n+1) As Integer
'随机生成n个两位正整数,存入数组a中,代码略
Private Sub Command2_Click()
For i = 1 To n \ 2
m =
For j = i To m
If a(j) > a(j + 1) Then t = a(j): a(j) = a(j + 1): a(j + 1) = t
Next j
k = m
For j =
If a(k) > a(j) Then k = j
Next j
If k <> i Then t = a(k): : a(i) = t
Next i
s = ""
For i = 1 To n
If a(i) \ 10 Mod 2 = 1 Then s = s + Str(a(i)) Else s = Str(a(i)) + s
If Then List2.AddItem s: s = ""
Next i
End Sub
根据上述加密算法编写解密程序。程序在启动时读取密钥矩阵存入数组a 中,在文本框Text1
中输入密文,点击“解密”按钮,在文本框Text2 中显示明文。运行界面如图c 所示。
Const n = 3
Dim a(1 To n * n) As Integer
Private Sub Command1_Click()
Dim mw(1 To 2*n*n) As Integer
'存储密文数据,奇数位存储加密值,偶数位存储该数据在原文中的位置
Dim yw(1 To n*n) As Integer '存储解密数据
Dim k As Integer
'生成规模为n*n 的密钥矩阵存入数组a中,代码略
For i = 1 To Len(Text1.Text)
c = Mid(Text1.Text, i, 1)
If c <> "," Then
t = t * 10 + Val(c)
Else
mw(k) = Val(t): t = 0
End If
Next i
For i = 1 To k\2 '对密文解密,结果存数组yw
yw(mw(2 * i)) =
Next i
s = ""
For i = 1 To k\2
s = s + Chr((yw(i)) + 64)
Next i
Text2.Text = s
End Sub
Function getmm(x As Integer, n As Integer)
col = (x - 1) Mod n + 1
row = (x - 1) \ n + 1
getmm = a((col - 1) * n + row)
If row Mod 2 = 0 Then getmm =
End Function