①x=y ②y=x ③t=x ④x=t ⑤y=t ⑥t=y
i= 1:j= 6:key=8
Do While i<= j
m=(i+j)\2
If a(m)<key Then
j=m- 1
Else
i=m+ 1
End If
Loop
数组元素a(1)到a(6)的值依次为“9,8,8,8,7,6”,运行该程序段后,下列说法正确的是( )
n=0:i=1:j=6
Key = Val (Text1. Text)
Do While i<=j
m=(i+j)\2
If Key = a(m) Then Exit Do
If Key > a(m) Then
i=m+1:n=n*2
Else
j=m-1:n=n-1
End If
Loop
若数组元素a(1)到a(6)的值依次为4, 11, 19, 26, 38, 45。运行该程序段后,变量n的值为-4,则文本框Text1输入的数字可能是( )
flag=False
i=0: j=7: c=0
Do While<= j And flag=False
m=Fix((i+j)/2+0.5)
If Key=a(m) Then flag=True
If Key< a(m) Then j=m-1 Else i=m+1
c=c+1
Loop
数组元素a(0)到a(7)的值依次为“1,3,30,46,6S,72,84,90”,key的值为85。若该程序段执行后,以下说法中正确的是( )
flag=False:s="ShanShui2020!"
For i=1 To Len(s)
ch=Mid(s,i,1)
If Not(ch〉="0"And ch<="9")And Not flag Then
t=ch+t
End If
flag=Not flag
Next i
Text1.Text=t
执行完以上程序段后,文本框text1中的内容为( )
请根据算法将下列程序补充完整。
Dim a(1 To 45) As String
Dim b(1 To 45) As Integer
Private Sub Form_Load()
a(1) = "中国"
b(1) = 308
‘45个代表团名称及奖牌数分别放在a(1)到a(45)及b(1)到b(45)中
End Sub
Private Sub Command1_Click()
Dim i As Integer,j As Integer
Dim t As Integer,f As Integer
List1.Clear
For i = 1 To 3
For j = To 2 Step -1
If Then
f = a(j): a(j) = a(j - 1): a(j - 1) = f
t = b(j): b(j) = b(j - 1): b(j - 1) = t
End If
Next j
Next i
For i = 1 To 3
List1.AddItem "第" + Str(i) + "名" + a(i) + " 奖牌数" + Str(b(i))
Next i
End Sub
已知数组a中依次存放了6个数:-1,4,12,10,-3,8,运行结果是。
图1
图2
图3