则下列说法正确的是( )
分析图中的信息,下列描述不正确的是:( )
For i = 1 To 2
For j = 2 To 7 - i
If a(j) > a(j - 1) Then
k = a(j): a(j) = a(j - 1): a(j - 1) = k
End If
Next j
Next i
数组元素a(1)到a(6)的值依次为“71,54,58,29,31,78”,经过该程序段“加工”后,下列说法正确的是( )
Dim s(1 To 6) As String
Text1.Text = ""
For i = 1 To 5
For j = i + 1 To 6
If s(i) + s(j) < s(j) + s(i) Then
t = s(j): s(j) = s(i): s(i) = t
End If
Next j
Next i
For i = 1 To 6
Text1.Text = Text1.Text + s(i)
Next i
如果程序运行,一开始当数组元素s(1)到s(6)的值依次为“4”、“343”、“312”、“12”、“246”、“121”,运行该段代码后,文本框Text1中显示的内容为( )
图a
图b
图c
图d
Private Sub Command1_Click()
Dim n As Long, k As Integer
Dim f1 As Long, f2 As Long, f As Long
=Val(Text1.Text)
If n >= 20 Or n <= 0 Then
Label2.Caption = "输入的数据有误"
Else
If n <= 2 Then ' 第1,2个元素的值都为1
f = 1
Else
f1 = 1
f2 = 1
For k = 3 To n
f = f1 + f2
f1 = f2
f2 = f
Nextk
End If
Label2.Caption = "斐波那契数列第" + Str(n) + "项的值为" +
End If
End Sub
图a
图b
Dim a(1 To 100) As Single '依次存储100个学生成绩
Const n = 100
Private Sub Form_Load()
'本过程从数据库中读取1到100号学生成绩,并存储在数组a中
'代码略
End Sub
Private Sub Command1_Click()
Dim i As Integer, max As single
max = ①
For i = 2 To n
if ②
Next i
Text1.Text = "成绩最高分是:" + Str(max)
End Sub
从被加密字符串中获取单个字符,然后得到其ascii码的8位二进制编码。
将字符的二进制编码反向,得到其逆序二进制码。
将逆序二进制码的每4位转换为相应的十六进制编码,即得到单个字符加密后的字符串。
以此类推,直到所有字符加密完成,得到加密字符串。
具体程序界面如下图,在text1中输入字符串,点击“加密”按钮command1后,在text2中显示加密后的字符串。
程序中②画线处应填入。
Private Sub Command1_Click()
Dim s As String, ch As String
Dim result As String, chA As String, chB As String
Dim i As Integer, j As Integer
Dim n As Integer, m As Integer
s = Text1.Text
n = Len(s)
result = "": c = "0123456789ABCDEF"
For i = 1 To n
ch = ①
ch = niXu(ch)
m = 0
For j = 1 To 4 ' 获取二进制码前4位的值
②
Next
chA = Mid(c, m + 1, 1)
m = 0
For j = 5 To Len(ch)
m = m * 2 + Val(Mid(ch, j, 1))
Next
chB = Mid(c, m + 1, 1)
result = result + chA + chB
Next
Text2.Text = result
End Sub
' 得到单个字符ch的8位二进制编码
Function D2B(ByVal ch As String) As String
Dim s As String
Dim data As Integer, i As Integer
data = Asc(ch):s = ""
Do While data > 0
s =Str(data Mod 2) + s
data = data \ 2
Loop
If Len(s) < 8 Then
For i = 1 To 8 - Len(s)
s = "0" + s
Next
D2B = s
Else
D2B = s
End If
End Function
' 返回字符串s的逆序
Function niXu(ByVal s As String) As String
Dim i As Integer:Dim r As String
r = ""
For i = Len(s) To 1 Step -1
r = r + Mid(s, i, 1)
Next
niXu = r
End Function