修改时间:2021-05-20 浏览次数:167 类型:月考试卷
Dim c As String, s1 As String
s = Text1.Text
s1 = ""
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "A" And c <= "Z" Then c = Chr((Asc(c) - Asc("A")) Mod 10 + Asc("0"))
If c >= "4" And c <= "9" Then c = Chr(Asc(c) - Asc("4") + Asc("a") + 1)
s1 = c + s1
Next i
Text2.Text = s1
在文本框Text1中输入“ELQ278yza ”,执行上述程序后,文本框Text2中输出( )
L = 1: R = n
Do While L < R
imin_1 = L: imin_2 = R
For i = L + 1 To R
If a(i) < a(imin_1) Then
imin_2 = imin_1
imin_1 = i
ElseIf a(i) < a(imin_2) Then
imin_2 = i
End If
Next i
If imin_1 <> L Then t = a(imin_1): a(imin_1) = a(L): a(L) = t
____________________
If imin_2 <> R Then t = a(imin_2): a(imin_2) = a(R): a(R) = t
L = L + 1: R = R - 1
Loop
Dim a(1 To 10) As Integer
Key = Int(Rnd * 32) * 3 + 3
s = 0: i = 1: j = 10
Do While i <= j
m = (i + j) \ 2
If Key = a(m) Then Exit Do
If Key > a(m) Then
i = m + 1: s = 3 * s + 2
Else
j = m - 1: s = 3 * s
End If
Loop
数组a(1)到a(10)的值依次为“4,7,9,15,24,32,37,54,75,90”,执行该程序段后,s的值不可能为( )
图a
图 b
图c
1图
请回答以下问题:
2图
3图
4图
⑴将原文转换为若干行m列(m为奇数)的矩阵,最后一行若不足m个数据则以“#”填充。
⑵将矩阵中的数据,从末行末列数据开始以回路的方式提取字符。按顺序生成加密字符。例如对字符“helloworld”,m=3的加密过程如下图,其加密结果为“#lwleor#dolh”
程序窗口界面如图:
请回答下列问题:
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
Dim a(1 To 5) As Integer
Dim n, k As Integer
Private Sub Form_Load()
n = Val(Text1.Text): k = Val(Text2.Text)
’随机生成n(n>=2)个不重复的0及以上的数字赋值给数组a,代码略
End Sub
Private Sub Command1_Click()
Dim m, l, r As Integer
For i = 1 To n
For j = 1 To n - i
If a(j) > a(j + 1) Then
t = a(j): a(j) = a(j + 1): a(j + 1) = t
End If
Next j
Next i
l = 1: r = a(n) - a(1)
Do While l <= r
m = (l + r) \ 2
If Then
l = m + 1
Else
r = m - 1
End If
Loop
Label1.Caption = Str(r)
End Sub
Function check(ByVal d As Integer) As Boolean
Dim cow, rgt As Integer
cow = 1
rgt = a(1) + d
For i = 2 To n
If a(i) >= rgt Then
cow = cow + 1
①
End If
Next i
If ② Then
check = True
Else
check = False
End If
End Function
① ②
试题篮