a(1) = "231": a(2) = "34": a(3) = "23": a(4) = "234": a(5) = "123"
For i = 1 To 4
For j = 1 To 5 - i
If a(j) > a(j + 1) Then t = a(j): a(j) = a(j + 1): a(j + 1) = t
Next j Next i
执行该程序段后,数组元素 a(1)到 a(5)的数据依次为( )
s = "2019.06 Visual Basic 6.0": n = 0 For i = 1 To Len(s)
ch = Mid(s, i, 1)
If ch >= "0" And ch <= "9" Then
m = Asc(ch) - Asc("0") + 1
a(m) = a(m) + 1
End If
Next i
For i = 1 To 10
If a(i) > 1 Then n = n + i
Next i
数组 a 各元素的初始值都为0,执行该程序段后,则变量n的值为( )
i=1:j=6:flag=False key=Val(Text1.Text)
Do While i<=j And flag = False
m=(i+j)\2
If key=a(m) Then flag=True
If key<a(m) Then j=m-1 Else i=m+1 Loop
数组元素a(1)到a(6)的值依次为“7,9,15,27,34,51”。文本框Text1中输入“27”后运行该程序,运行结束后,下列说法不正确的是( )
a(i)= Int(Rnd * 20) + 1 Next i
For i= 2 To 5
If i Mod 2 = 1 And a(i-1) < a(i)Then t=a(i):a(i)=a(i-1):a(i-1)=t
Else
a(i)=a(i)-1 End If
Next i
执行该程序段后,a(1)~ a(5)各元素不可能的值是( )
Dim a(8) As Integer For i = 2 To 8
a(0) = a(i)
Do While a(0) < a(j)
j = j - 1
Loop
Next i
数组元素 a(1)~a(8)的值为随机生成的整数,为实现升序排序,则上述程序段3个方框处的表达式分别为( )
图b
图a
图b
图c
实现上述功能的VB程序如下,请回答下列问题:
Private Sub Command1_Click()
Dim a(20) As Long
Dim i As Integer, j As Integer, s As String List1.Clear
n = Val(Text1.Text)
a(1) = 1
List1.AddItem Str(a(1)) For i = 2 To n
s = ""
For j = Step -1
a(j) = ①
s = s + Str(a(j))
Next j
② Next i
① ②
实现上述功能的VB程序如下,请回答下列问题。
Private Sub Command1_Click()
Dim i As Integer, n As Integer, m As Integer
Dim num As Integer, t As Integer
Dim a(1 To 100) As Boolean
n = Val(Text1.Text)
m = Val(Text2.Text)
For i = 1 To n
a(i) = True
Next i
①
Do While t > 1
For i = 1 To n
If a(i) = True Then ②
If num = m The
③
t = t - 1
num = 0
Text3.Text = Text3.Text + Str(i)
End If
Next i
Loop
For i = 1 To n
If a(i) = True Then Label2.Caption ="获得礼品同学编号:" + Str(i)
Next i
End Sub
① ② ③