s = "Happy new year↑”
flag=False:m=0
For i=1 To Len(s)
c= Mid(s,i,1)
If c >=“a" And c <= "z” Then
If Not flag Then
m=m+1
flag=True
End If
Else
flag = False
End If
Next i
n =1
For i=2 To 12
If ⑴ Then
n=n+1
⑵
End If
Next i
S=””
For i=1 To n
s=s+Str(a(i))
Next i
Text1.Text = s
上述程序中划线处可选语句为:①a(i)<>a(n) ②a(i)=a(n) ③a(n)=a(i)
则(1)、(2)处语句依次是( )
Const n=8
a(1)=33:a(2)=8:a(3)=49:a(4)=25:a(5)=56:a(6)=3:a(7)=12:a(8)=41
x=n\2
For i=x To 2 Step-1
For j=1 To i - 1
If a(j)< a(i) Then
t=a(j):a(j)=a(i):a(i)=t
End If
Next j
Next i
i =n
Do While i>x+ 1
k=i
For j=i-1Tox+1 Step -1
If a(j)>a(k) Then k=j
Next j
If k<>I Then
t=a(k):a(k)=a(i):a(i)=t
End If
i=i-1
Loop
执行完这段代码后,数组a中各个元素的值为( )
i =1:j = 10: n=0: flag = True
Key = Val (text1.Text)
Do While i<=j And flag=True
n=n+1
m=(i+j)\2
If a(m) = Key Then flag = False
If Key > a(m) Then i = m+1 Else j=m-1
Loop
数组元素a(1)到a(10)的值依次是:“5,12,23,29,34,48,51,67,70,89”,key值为57时,运行结束后下列说法正确的是( )
①将密文进行转换为一个十进制数值:例如密文242转换的表达式为:2*53+4*5*+2*5*=72 对应的明文字符为大写“H":
②得到的数值就是对应明文的ASCII 字符的十进制编码(提示:空格所对应的ASCII值为十进制32,小写字母“z”所对应的ASCII值为十进制数122);
程序运行界面如下图所示。在文本框Text1中输入密文,单击“解密”按钮,在文本框Text2 中输出解密后的明文密码。实现上述功能的VB代码如下:
Private Sub Convnand1_Click()
Dim st, p, c1, c2, c3 As String
Dim i, d, res As Integer
st = Text1.Text: n = Len(st)
i=1:res=””
Do While i <=n- 2 '提取有效密文,并进行转换
c1 = Mid(st, i, 1): c2 = Mid(st, i + 1, 1): c3= Mid(st, i +2, 1)
If Then ‘①
p = Mid(st, i, 3)
d = conv(p)
If d>=32 And d<=122 Then res= res + Chr(d)
②
Else
i =i+1
End If
Loop
Text2 Text = ③
End Sub
‘以下代码是将有效密文数字转换为十进制数的函数
Function conv(p As String) As Integer
Dim k As Integer, q As String, i As Integer
k=0:q=””
For i =ITo 3
q = Mid(p, i, 1)
④
Next i
conv=k
End Function
实现上述功能的VB程序如下,请回答下列问题:
Dim xn(1 To 50) As String, sg(1 To 50) As Integer
Dim n as integer, i as integer, j as integer, ch as string, t1 8s string, t2 as integer
Private sub form_load( ) ‘把数据表中姓名和身高分别存储到数组xm( )和sg( ),代码略
‘按身高从低到高对学生数据进行排序,代码略
List1.Clear
List1.AddItem“第一组”+“第二组”+“第三组”+“第四组”
List1.AddItem
“------------------------------------------------------------”
‘将排序好的学生姓名按6行8列的格式输出在列表框list1中
For i=1 To n
ch=ch+xm(i)+””
If i Mod2=0 Then ch=ch+””
If Then
List1.Addltem ch
ch=””
End If
Next i
End Sub
Private Sub Com1_Click( )
Dim a(1 To 50) As String, b(1 To 50) As String
Dim st As String
‘下面进行组与组之间的调换,调换后的数据保存在数组a中
For i =1 To 6
For j=1 To 8
a((-1)*8+j)=
Next j
Next i
‘下面进行同桌之间互换位置,互换后的数据保存在数组b中
For i=1 To 6
For j=1 To 8
If j Mod2=1 Then
b((-1)*8+j)=
Else
b((i-1)*8+j)=a((-1)*8+j-1)
End If
Next j
Next i
‘在列表框List2中输出轮换后的结果,代码略
‘下面进行数据重新赋值,为下一次轮换做准备
For i=1 To 48
xm(i)单b(i)
Next i
End Sub