①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
數(shù)組元素a(1)到a(6)的值依次為“9,8,8,8,7,6”,運(yùn)行該程序段后,下列說法正確的是( )
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
若數(shù)組元素a(1)到a(6)的值依次為4, 11, 19, 26, 38, 45。運(yùn)行該程序段后,變量n的值為-4,則文本框Text1輸入的數(shù)字可能是( )
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
數(shù)組元素a(0)到a(7)的值依次為“1,3,30,46,6S,72,84,90”,key的值為85。若該程序段執(zhí)行后,以下說法中正確的是( )
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
執(zhí)行完以上程序段后,文本框text1中的內(nèi)容為( )
請(qǐng)根據(jù)算法將下列程序補(bǔ)充完整。
Dim a(1 To 45) As String
Dim b(1 To 45) As Integer
Private Sub Form_Load()
a(1) = "中國"
b(1) = 308
‘45個(gè)代表團(tuán)名稱及獎(jiǎng)牌數(shù)分別放在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) + " 獎(jiǎng)牌數(shù)" + Str(b(i))
Next i
End Sub
已知數(shù)組a中依次存放了6個(gè)數(shù):-1,4,12,10,-3,8,運(yùn)行結(jié)果是。
圖1
圖2
圖3